idiom for constructor?
cmgreen at uab.edu
Wed Jun 1 20:17:11 CEST 2005
"Mac" <idontneednostinkinid at yahoo.com> writes:
> Is there a nice Python idiom for constructors which would expedite the
> class Foo:
> def __init__(self, a,b,c,d,...):
> self.a = a
You could try:
args = locals()
for arg in args.keys():
self.__dict__[arg] = args[arg]
I don't think it saves you a whole lot of typing (and gains you a lot
of ugly complexity). I find as soon as I do this, I then want to
manipulate a,b,c,d .
You might look to see if you can customize your editor to use
templates/interaction and then inserts the right text for you.
Chris Green <cmgreen at uab.edu>
"Yeah, but you're taking the universe out of context."
More information about the Python-list