initializing mutable class attributes
F. Petitjean
littlejohn.75 at noos.fr
Mon Aug 30 12:29:02 EDT 2004
On Mon, 30 Aug 2004 15:39:54 GMT, Dan Perl <dperl at rogers.com> wrote:
>
> "Alex Martelli" <aleaxit at yahoo.com> wrote in message
> news:1gjc8cs.sqvo1v1fhabdjN%aleaxit at yahoo.com...
>
>> > So the only solution I see to this is to initialize attr2 in __init__:
>> > class Father:
>> > attr1=None
>> > def __init__(self):
>> > self.attr2=[ ]
>>
>> This is the canonical way, sure.
>>
Snip
>
> After seeing a few replies (yours, Benjamin Niemann's and Peter Otten's) to
> my initial posting, I think I am getting the picture that there is a
> conscious decision to keep the use of __init__ the way it is and just make
> people learn it and learn it early enough. That's a valid approach and I'll
> accept it.
>
Snip
>
> No one, including you, has given me a reason WHY __init__ is implemented
> this way. I am not bashing you for that, I would just still like to hear
> that 'WHY'. I'm sure that this implementation has some advantages. But,
Explicit is better than implicit
import this
>
>
> Dan
> PS: Does my last name attract the wrong kind of attention from people in
> this newsgroup? It's really my name, it's not fake, BTW.
My nick littlejohn is the direct translation of my last name and I'm
far from big. So what ? :=)
More information about the Python-list
mailing list