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.
Due to the reasons discussed here we will be moving to on October 1, 2016.

This forum will be locked down and no one will be able to post/edit/create threads, etc. here from thereafter. Please create an account at the new site to continue discussion.
User avatar
Posts: 3000
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 9 guests