473,401 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

Override method name and original method access

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
0 2419

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: John Bailo | last post by:
I want to name a variable in a form Move. But Move() is a method, (Control.Move) that the form inherits. Can I override a method and have a variable with the same name that I can access...
14
by: JPRoot | last post by:
Hi I use the following syntax to have events inherited from base to child classes which works nicely (virtual and override keyword on events). But I am wondering if it is a "supported" way of using...
5
by: Darius | last post by:
I'm writing here in hopes that someone can explain the difference between the new and virtual/override keywords in C#. Specifically, what is the difference between this: public class Window {...
5
by: Mark Broadbent | last post by:
Oh yes its that chestnut again! Ive gone over the following (http://www.yoda.arachsys.com/csharp/faq/ -thanks Jon!) again regarding this subject and performed a few of my own tests. I have two...
4
by: Sharon Tal | last post by:
Hi all. I am trying to figure out the differences between overriding and hiding a method name. The only difference i can see, is that with name hiding i can change the method access level. Are...
15
by: John Salerno | last post by:
Hi all. I have a question about virtual and override methods. Please forgive the elementary nature! First off, let me quote Programming in the Key of C#: "Any virtual method overridden with...
5
by: Marcel Hug | last post by:
Hi NG ! I'm new in C# and I'm reading a book about the fundamentals and concepts. In the chapter Methods it's written to use virtual, if i would like to override the method in a subclass. This...
14
by: Dave Booker | last post by:
It looks like the language is trying to prevent me from doing this sort of thing. Nevertheless, the following compiles, and I'd like to know why it doesn't work the way it should: public class...
0
by: Fabrizio Pollastri | last post by:
Hello, I am trying to override a method of a class defined into an imported module, but keeping intact the namespace of the imported module. For example, let suppose import module_X and in...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.