Newbie inheritance question.
Mark McEahern
marklists at mceahern.com
Sun Jan 16 09:26:39 EST 2005
bwobbones wrote:
> Hi all,
>
> I'm a java programmer struggling to come to terms with python - bear
> with me!
Welcome!
> I'm trying to subclass a class, and I want to be able to see it's
> attributes also. Here are my classes:
[snip]
> class two(one):
> def __init__(self):
> print "two"
The problem is that you're not calling the parent class' __init__::
class two(one):
def __init__(self):
one.__init__(self)
...
You can also use super() to do that, but I do that so rarely I forget
the syntax. Of course, that's no big deal, since::
python
>>> help(super)
is always to the rescue, but I'm lazy.
// m
More information about the Python-list
mailing list