Subclassing by monkey-patching
Bruno Desthuilliers
bruno.42.desthuilliers at websiteburo.invalid
Mon Sep 6 04:08:06 EDT 2010
Jason a écrit :
> On Sep 5, 3:53 pm, Peter Otten <__pete... at web.de> wrote:
>>>>> m = gio.File(".").monitor_directory()
>>>>> C = type(m)
>
> 'C' will not necessarily be 'gio.FileMonitor' — I think the internals
> of the GIO methods might further "subclass" it in some way depending
> on what underlying monitors are available.
>
>> A possible alternative may be a class that wraps a FileMonitor instead of
>> subclassing it.
>
> I've been avoiding this because it involves a lot of boilerplate: the
> signals needs to be replicated and passed through, same for all
> GObject properties, same for the usual methods.
Python is not Java !-)
http://docs.python.org/reference/datamodel.html#object.__getattr__
More information about the Python-list
mailing list