idiom for constructor?

Terry Reedy tjreedy at udel.edu
Wed Jun 1 23:44:43 CEST 2005


"Mac" <idontneednostinkinid at yahoo.com> wrote in message 
news:1117648259.190124.76800 at f14g2000cwb.googlegroups.com...
> Is there a nice Python idiom for constructors which would expedite the
> following?
>
> class Foo:
>  def __init__(self, a,b,c,d,...):
>    self.a = a
>    self.b = b
>    self.c = c
>    self.d = d

Do you like this better?

self.a, self.b, self.c, self.d = a,b,c,d

For my own code, I might use 's' instead of 'self' to save typing...

Terry J. Reedy







More information about the Python-list mailing list