package extension problem
malaclypse2 at gmail.com
Mon Feb 13 19:00:52 CET 2012
On Sun, Feb 12, 2012 at 1:46 PM, Fabrizio Pollastri <f.pollastri at inrim.it>wrote:
> I wish to extend the functionality of an existing python package by
> a new package that redefines the relevant classes of the old package. Each
> new class inherits the equivalent old class and adds new methods.
There is a way to solve this problem without redefining in the new package
> all the
> methods of the old package that return old classes?
The general answer is no. If you want the methods of your subclass to
behave differently, in any way, from the same methods in the superclass,
then you must write new code that defines the behavior that you want.
Sometimes people write their classes so they automatically play nicely when
subclassed, and sometimes they don't. In general, it's impossible to
always do the right thing when you don't know what particular behavior a
subclass might need to override, so a lot of times people don't bother to
write their classes to check for subclasses being passed in, etc.
Since you haven't actually shown us any code, that's about all I can tell
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list