Marco Wahl a écrit :
(snip)
> The __new__ method should return the class.
s/class/instance/
--
http://mail.python.org/mailman/listinfo/python-list
Colin J. Williams wrote:
> rzed wrote:
>> class T(object):
>> def __new__(self):
>> self.a = 1
>> ...
>> t = T()
>>
>> and I want to examine the 'a' attributes.
>>
> print T.a
>> 1
> print t.a
>> Traceback (most recent call last):
>> File "", line 1, in
>> AttributeError: 'No
rzed wrote:
> I'm confused (not for the first time).
>
> I create these classes:
>
> class T(object):
> def __new__(self):
> self.a = 1
>
> class X(T):
> def __init__(self):
> self.a = 4
>
> class Y:
> def __init__(self):
> self.a = 4
>
> class Z(object):
>
rzed <[EMAIL PROTECTED]> writes:
To simplify take
> class T(object):
> def __new__(self):
> self.a = 1
and
t = T()
and then you get
>>> print t.a
> Traceback (most recent call last):
> File "", line 1, in
> AttributeError: 'NoneType' object has no attribute 'a'
While T.a is 1.
I'm confused (not for the first time).
I create these classes:
class T(object):
def __new__(self):
self.a = 1
class X(T):
def __init__(self):
self.a = 4
class Y:
def __init__(self):
self.a = 4
class Z(object):
def __init__(self):
self.a = 4
..