Peter Otten wrote:
Terry Reedy wrote:
If the names of superclasses is resolved when classes are instantiated,
the patching is easy. If, as I would suspect, the names are resolved
when the classes are created, before the module becomes available to the
importing code, then much more careful a
Wow, thank you all. Lots of ideas and things to try! I wish I knew
which one is going to work best. The module I'm trying to (monkey!)
patch is pxdom, and as it is a bit long (5700 lines of code in one
file!) I'm not quite sure if the simplest patching method will work or
the more complicated o
Terry Reedy wrote:
> Steven D'Aprano wrote:
>> On Sat, 16 May 2009 09:55:39 -0700, Emanuele D'Arrigo wrote:
>>
>>> Hi everybody,
>>>
>>> let's assume I have a module with loads of classes inheriting from one
>>> class, from the same module, i.e.:
>> [...]
>>> Now, let's also assume that myFile.py
Try this:
class Base(object):
pass
class C(Base):
pass
class NewBase(object):
pass
C.__bases__ = (NewBase,)
help(C)
--
http://mail.python.org/mailman/listinfo/python-list
Steven D'Aprano wrote:
On Sat, 16 May 2009 09:55:39 -0700, Emanuele D'Arrigo wrote:
Hi everybody,
let's assume I have a module with loads of classes inheriting from one
class, from the same module, i.e.:
[...]
Now, let's also assume that myFile.py cannot be changed or it's
impractical to do
On Sat, 16 May 2009 09:55:39 -0700, Emanuele D'Arrigo wrote:
> Hi everybody,
>
> let's assume I have a module with loads of classes inheriting from one
> class, from the same module, i.e.:
[...]
> Now, let's also assume that myFile.py cannot be changed or it's
> impractical to do so. Is there a w
"Emanuele D'Arrigo" writes:
> On May 16, 8:17 pm, Arnaud Delobelle wrote:
>> # Insert Wedge into each subclass of modfoo.Base
>> for subclass in modfoo.Base.__subclasses__():
>> if subclass.__module__ != 'modfoo': continue
>> attrs = dict(item for item in subclass.__dict__.items()
>>
On May 16, 8:17 pm, Arnaud Delobelle wrote:
> # Insert Wedge into each subclass of modfoo.Base
> for subclass in modfoo.Base.__subclasses__():
> if subclass.__module__ != 'modfoo': continue
> attrs = dict(item for item in subclass.__dict__.items()
> if item[0][:2] !=
"Emanuele D'Arrigo" writes:
> Hi everybody,
>
> let's assume I have a module with loads of classes inheriting from one
> class, from the same module, i.e.:
>
> ## myFile.py
> class SuperClass(object)
> class SubClass1(SuperClass)
> class SubClass2(SuperClass)
> class SubClass3(SuperClass)
>
> In