super confused !
robin and jim
robinjim at earthlink.net
Thu Feb 28 21:18:01 EST 2002
I'm confused about the behavior of "new-style" classes in Python 2.2.
Here is a sample session that illustrates my confusion.
>>> class Int_a(int):
... def __init__(self, spec):
... super(Int_a, self).__init__(spec)
...
>>> Int_a(1)
1
>>> class Int_b(Int_a):
... def __init__(self, spec):
... super(Int_b, self).__init__(spec)
...
>>> Int_b(2)
2
>>> class Int_c(Int_a):
... def __init__(self):
... super(Int_c, self).__init__(99)
...
>>> Int_c()
0
>>> class Int_d(Int_a):
... def __init__(self):
... Int_a.__init__(self, 99)
...
>>> Int_d()
0
Why are Int_c() and Int_d() zero (the default for int()) rather than 99?
How can I make them 99?
Thanks for your interest.
More information about the Python-list
mailing list