another syntax we don't need (initializers)

Greg Ewing see_reply_address at something.invalid
Mon Dec 9 20:09:06 EST 2002


Andrew Koenig wrote:

> Is this really an advantage over
> 
>           class Foo:
>               def __init__(self, x): self.x = x
> 
> ? The latter version is only one character longer!


And if you've got more than one instance variable to
initialise, there's always the old favourite

   class Foo:
     def __init__(self, **kw):
       self.__dict__.update(kw)

-- 
Greg Ewing, Computer Science Dept,
University of Canterbury,	
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg




More information about the Python-list mailing list