"Mac" <[EMAIL PROTECTED]> writes:

> 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
>     ...

You could try:

class Foo:
   def __init__(self,a,b,c,d):
       args = locals()
       for arg in args.keys():
           if name!='self':
              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 <[EMAIL PROTECTED]>
"Yeah, but you're taking the universe out of context."
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to