By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,995 Members | 1,217 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,995 IT Pros & Developers. It's quick & easy.

Override method name and original method access

P: n/a
In an unusual twist of code I have a subclass which overrides a method but
it also needs to call the original method:

class One:
def add (self, stuff):
self.stuff.append(stuff)

class Two(One):
def __init__(self, otherstuff):
<MYSTERY>(otherstuff) #otherstuff must go into list within the parent.
#The override - totally different function in this context.
def add (self, data):
self.unrelated.append (data)

For:
<MYSTERY>
I have tried:
self.One.add( otherstuff )
No go.
super ( Two, self).add( otherstuff )
Gives this error:TypeError: super() argument 1 must be type, not classobj
(Which reminds me, how the heck does super work? I always get that error!)

I could just change the method name to adddata() or something. I could pass
parent references around, but want to avoid that.

I thought I'd ask about it here.

\d

Nov 12 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.