__autoinit__ (Was: Proposal: reducing self.x=x; self.y=y; self.z=z boilerplate code)
Reinhold Birkenfeld
reinhold-birkenfeld-nospam at wolke7.net
Mon Jul 11 02:34:45 EDT 2005
Kay Schluehr wrote:
> Dan Sommers schrieb:
>
>> How about this:
>>
>> def __init__(self, self.x, y, self.z):
>> # self.x, self.z from first and third explicit parameters
>> do_something_with_y()
>
> Can you tell me in which way it is anyhow better than the original
> proposal
>
> def __init__(self, .x, y, .z):
> # self.x, self.z from first and third explicit parameters
> do_something_with_y()
>
> besides that it is more verbose?
It is more explicit. Explicit is better than implicit.
But as with many proposals, this raises consequential questions, for
example, how "self.x" parameters are handled in other methods, or even
functions, as __init__ is not special-cased by the parser.
Reinhold
More information about the Python-list
mailing list