can a subclass method determine if called by superclass?

Peter peter.milliken at gmail.com
Wed Jan 4 18:37:55 EST 2012


On Jan 5, 10:09 am, Ian Kelly <ian.g.ke... at gmail.com> wrote:

>
> Well, you could get the previous stack level using
> traceback.extract_stack() and check the filename.  But it sounds like
> what you actually have are two different methods -- one that is used
> by the superclass, and one that only the subclass knows about and
> uses.  Why not implement it as such?

Thanks Ian - that is one possibility.

I am trying to create a subclass with slightly different functionality
and use it with an existing code base i.e. there is already one or
more modules that instantiate the current superclass and I want to
just drop in this new class to replace it with no ripples up the line
(so to speak). The new class implements some interface changes that
can safely be hidden from the rest of the application.



More information about the Python-list mailing list