Python capability do like plugins ?

L

Leon

example :
/home/test/plugins
a.py
b.py
c.py

main program can dynamic import plugins directory's files....not normal
¡uimport¡v
like winamp
 
A

Alex Martelli

Leon said:
example :
/home/test/plugins
a.py
b.py
c.py

main program can dynamic import plugins directory's files....not normal
¡uimport¡v
like winamp

The main program can insert the plugins directory into sys.path and
import at will (e.g with __import__) or do it with the imp module or in
several other ways. There's a number of recipes in the cookbook...


Alex
 
L

Leon

Thanks.....
I use a simple method...

sys.commands module --> get file list
re module --> filter file name and path
imp module --> load module
getattr() --> get varabiles

because none dll for unix, I don't know how to use *.pyd
and how to make *.pyd from *.py
 
A

Alex Martelli

Leon said:
Thanks.....
I use a simple method...

sys.commands module --> get file list
re module --> filter file name and path
imp module --> load module
getattr() --> get varabiles

because none dll for unix, I don't know how to use *.pyd
and how to make *.pyd from *.py

Not sure what you mean by "because none dll for unix". A *.pyd on
Windows is a DLL (meant for Python extension); you cannot make it from a
*.py, you make it from a *.c or the like. Equivalent on different Unix
variants are *.so, *.dynlib, and others yet.


Alex
 
L

Leon

Thank you very much,help me understand it ^_^
Now,I only use it (simple soluation). if other better soluation when modify
it
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top