Python style question
Martin Pool
mbp at sourcefrog.net
Sat Jun 4 02:46:00 BST 2005
Since we seem to have some experienced pythonists here:
I have a factory, find_branch, which can return instances of Branch or
RemoteBranch depending on a parameter. (Perhaps it should return
Branches which contain a BranchStorage of various types, but ignore
that for the moment.) What is good Python style for an abstract
factory?
One way is a simple function, as here. Another way is a static method
like Branch.open(). I suppose one might also override the call method
for Branch so that it possibly constructs a subclass(?)
The function works fine but I just wondered if there were any comments
on idioms that work well?
--
Martin
More information about the bazaar
mailing list