Possible Duplicate:
Assign function arguments to `self`
Often I have constructors that look like the following:
class Foo(object):
def __init__(self,a,b,c):
self.a = a
self.b = b
self.c = c
I was wondering if there was a convenient way to encode constructors like this. Perhaps something that looks like:
class Foo(object):
SOME_MACRO_LIKE_THINGY_THAT_SPECIFIES_THE_CONSTRUCTOR(a,b,c)
that would behave exactly like the original code above.
What bugs me with the original version is that I have to write each instance variable of Foo three times (once as an argument, once as self.a and once again as the value to assign to self.a).
I suppose it's not that big a deal, but I feel like the code would look neater with less repetition.
What is the Pythonic way to handle this situation?