Subclassing by monkey-patching
Jason
jason.heeris at gmail.com
Sun Sep 5 04:54:05 EDT 2010
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. I'd basically have to
re-write the entire class in Python, and then tack on my methods.
Otherwise I have to write two sets of methods for anything that
touches this wrapped object.
Still, if it's the only way, sure.
— Jason
More information about the Python-list
mailing list