[Tutor] super() and inherited attributes?

2005-06-27 Thread Marcus Goldfish
Hi, The following example doesn't work as I would like-- the child instance doesn't expose the attribute set in the parent. Can someone point out what I am missing? Thanks, Marcus class Parent(object): def __init__(self, name="I am a parent"): self.name = name class Child(Parent):

Re: [Tutor] super() and inherited attributes?

2005-06-27 Thread Brian van den Broek
Marcus Goldfish said unto the world upon 28/06/2005 00:58: > Hi, > > The following example doesn't work as I would like-- the child > instance doesn't expose the attribute set in the parent. Can someone > point out what I am missing? > > Thanks, > Marcus > > > class Parent(object): >def __

Re: [Tutor] super() and inherited attributes?

2005-06-28 Thread Alan G
|class Parent(object): | def __init__(self, name="I am a parent"): | self.name = name | |class Child(Parent): | def __init__(self, number): | super(Parent, self).__init__("I am a child") | self.number = number | |# I would like it to produce the following: |>> c = Child(23) |>> c

Re: [Tutor] super() and inherited attributes?

2005-06-28 Thread jfouhy
Quoting Alan G <[EMAIL PROTECTED]>: > I don't know the direct answer but the more common way > of doing that in Python is not to use super() but just > call the inherited constructor directly: > > Parent.__init__(self,'I am a child') > > > SO if you just want to fix the itch use that, if you