"Kent Johnson" <ken...@tds.net> wrote
> We can fake the Delphi style by using a default constructor and then
> just
> calling the "constructors" after initialisation:
> But its two lines not one... :-(
Why not this?
class C:
def __init__(self): pass
@staticmethod
def LoadFromFile(fname, count):
c = C()
# init c from the file
return c
and similar for Create(). Client code is one line:
c = C.LoadFromFile(fn, cnt)
Why not indeed?! I must remember that pattern for future reference.
Wish I'd thought of it a few months ago when I was wrestling with a
problem that could have used multiple constructors!
Alan G.
_______________________________________________
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor