Class design issues: multiple constructors
Greg Brunet
gregbrunet at NOSPAMsempersoft.com
Thu Aug 7 11:12:53 EDT 2003
Hi Miki:
> I see two ways:
> 1. Module (not class) methods: db = opendb(..), db = createdb(...)
> 2. Passing keyword arguments.
> def __init__(selfk, filename, **kw):
> if kw.has_key(create):
> ....
>
> I vote for the former.
Thanks for the response. I lie the first also - what function is being
called is more clear than option 2 which would require extra tests
(depending on how many __init__ variations there are). If I can
understand the staticmethod stuff that Alex mentioned in his message, I
may try that path , since I'd like to have the methods actually in the
class definition, but defining them in the module itself is definitely a
good option. Thanks,
--
Greg
More information about the Python-list
mailing list