Cast into custom type

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Tue Nov 3 05:08:03 EST 2009


En Tue, 03 Nov 2009 06:41:37 -0300, Henning Bredel <henning.bredel at gmx.de>  
escribió:

> I created a plugin mechanism for my application orientating
> at the mechanism described by Martin Alchy in
>
>   http://martyalchin.com/2008/jan/10/simple-plugin-framework/
>
> Now I'd like to call methods like `initialize(parent)' when
> the user chooses to use a plugin. As described in the blog
> mentioned above, I only have access to the general type called
> `PluginMount' (holding all the actual plugin instances).

According to the article, PluginMount holds a list of all plugin *classes*  
defined, not instances.

> I tried to define "abstract" methods in PluginMount type
> raising a `NotImplementedError' but it seems, there is no
> late binding (similar to Java), so the right method would be
> called. Only the message
>
>   TypeError: unbound method initialize() must be called
>   with GeoCache instance as first argument (got PluginMount
>   instance instead)

Python uses "late binding", even more than Java. A reference like  
obj.foo(...) searches for "foo" along obj's attributes at runtime.
Please post some code showing your issue, and don't forget to tell us what  
is your expected result, and what you actually get.

-- 
Gabriel Genellina




More information about the Python-list mailing list