How to write python plug-ins for your own python program?
Reinhold Birkenfeld
reinhold-birkenfeld-nospam at wolke7.net
Sat Mar 5 03:48:18 EST 2005
David M. Cooke wrote:
> Simon Wittber <simonwittber at gmail.com> writes:
>
>>> You mean like 'import'? :)
>>
>> That's how I would do it. It's the simplest thing, that works.
>>
>> exec("import %s as plugin" % pluginName)
>> plugin.someMethod()
>>
>> where pluginName is the name of the python file, minus the ".py" extension.
>
> You'd better hope someone doesn't name their plugin
> 'os; os.system("rm -rf /"); import sys'
^
Well, that would be difficult, but "rm -rf ~" would work rather nicely...
Of course, one could test pluginName that it contains only
alphanumerics, but
> Use __import__ instead.
is surely the better solution.
Reinhold
More information about the Python-list
mailing list