On Mon, Jun 1, 2009 at 4:55 PM, Alan Gauld <[email protected]> wrote:
> We can fake the Delphi style by using a default constructor and then just
> calling the "constructors" after initialisation:
>
> class C:
> def __init__(): pass
> @constructor
> def LoadFromFile(fname, count): ...
> �...@constructor
> def Create(valueTuple):...
>
> c = C()
> c.LoadFromFile(fn, cnt)
>
> 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)
Kent
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor