How do I call anonymous classes from imported modules?

JoeSox joesox at gmail.com
Mon Aug 20 09:53:52 EDT 2007


On 8/19/07, James Stroud <jstroud at mbi.ucla.edu> wrote:
> This was the poor design I was hinting to. do_foobar is type-checking
> for ticker. "Casting" as you might think of it does not exist in python.
> Creating new objects based on the values of existing objects (lets call
> it "conversion" for lack of a better name) does (e.g. int(2.0)). But
> this is not casting. Unless you have the power to re-author all of the
> do_foobar()s to not type-check, you should create an instance of ticker
> and pass that:
>
> t = ticker(param1, param2, parametc)
> [...]
>               anobj.do_foobar(t)
>
> The "got nothing instead" means that you should have passed an
> argument--and unfortunately whoever authored do_foobar() type-checked
> for a ticker, which is not a desirable way to design an API.

I designed the system using this 'tutorial'
http://lucumr.pocoo.org/blogarchive/python-plugin-system

With your help and revisiting the article I figured out that this call works:
>>> for plugin in get_plugins_by_capability('do_foobar'):
	plg=plugin()
	print plg.do_foobar()

--
Thanks, Joe



More information about the Python-list mailing list