How to bypass a method in Python..?

This is the place for queries that don't fit in any of the other categories.

How to bypass a method in Python..?

Postby 9491731751 » Tue Sep 24, 2013 5:27 am

Here is the scenario.

I have a class(X) having method(xyz)

I have to define a class(Y) which extends class(X) but should run method(pqr) instead of method(xyz)

Here is the example :

Code: Select all
class X():
    def method(self):

class Y(X):
    def method(self):
        -----Actually, my requirement is to call "Y.method()" whenever "X.method()" is called and I can't do modifications in 'Class X' but I can modify 'Class Y'.

Could anyone please clarify this.
Posts: 1
Joined: Tue Sep 24, 2013 5:21 am

Re: How to bypass a method in Python..?

Postby micseydel » Tue Sep 24, 2013 6:00 am

I don't believe what you want is possible in Python, and for good reason. If you can explain why you want this though, we can probably tell you a better way to do it.
Join the #python-forum IRC channel on for off-topic chat!

Please prefer not to PM members. The point of the forum is so that anyone can benefit. We don't want to help you over PMs/emails/Skype chats that others can't benefit from :)
User avatar
Posts: 2917
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

Return to General Coding Help

Who is online

Users browsing this forum: No registered users and 5 guests