Problem--Extending the behavior of an upstream package

Aahz aahz at pythoncraft.com
Wed Mar 11 00:33:19 EDT 2009


In article <60848752-2c3f-4512-bf61-0bc11c919f99 at i20g2000prf.googlegroups.com>,
Carl Banks  <pavlovevidence at gmail.com> wrote:
>
>The problem comes when a different part of the upstream package also
>subclasses or creates a Box.  When an upstream function creates a box,
>it creates an upstream.packaging.Box instead of a
>mine.custom_packaging.Box, but I'd want it to do the latter.

The only clean way I'm aware of is to pass in an instance and use
instance.__class__ to create new instances.  Did you come up with
another idea?
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"All problems in computer science can be solved by another level of     
indirection."  --Butler Lampson



More information about the Python-list mailing list