Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #20286

package extension problem

Date 2012-02-12 19:46 +0100
From Fabrizio Pollastri <f.pollastri@inrim.it>
Subject package extension problem
Newsgroups comp.lang.python
Message-ID <mailman.5734.1329072778.27778.python-list@python.org> (permalink)

Show all headers | View raw


Hello,

I wish to extend the functionality of an existing python package by creating
a new package that redefines the relevant classes of the old package. Each
new class inherits the equivalent old class and adds new methods.

In the new package there is something like the following.

import old_package as op

class A(op.A):
     ...
     add new methods
     ...

class B(op.B):
     ...
     add new methods
     ...

Some classes of the old package works as a dictionary of other classes 
of the
same old package. Example: if class A and class B are classes of the old 
package,
B[some_hash] returns an instance of A.

When a program imports the new package and create instances of the new 
class B,
B[some_hash] still returns an instance of the old class A, while I want
an instance of the new class A.

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?


Thanks in advance for any suggestion,
Fabrizio

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

package extension problem Fabrizio Pollastri <f.pollastri@inrim.it> - 2012-02-12 19:46 +0100
  Re: package extension problem Miki Tebeka <miki.tebeka@gmail.com> - 2012-02-13 09:18 -0800
    Re: package extension problem Fabrizio Pollastri <f.pollastri@inrim.it> - 2012-02-13 18:53 +0100
      Re: package extension problem Miki Tebeka <miki.tebeka@gmail.com> - 2012-02-13 09:58 -0800
        Re: package extension problem Terry Reedy <tjreedy@udel.edu> - 2012-02-13 14:12 -0500
      Re: package extension problem Miki Tebeka <miki.tebeka@gmail.com> - 2012-02-13 09:58 -0800
    Re: package extension problem Peter Otten <__peter__@web.de> - 2012-02-13 19:28 +0100
  Re: package extension problem Miki Tebeka <miki.tebeka@gmail.com> - 2012-02-13 09:18 -0800

csiph-web