Python Importing Dynamically

  • From: Storm Dragon <stormdragon2976@xxxxxxxxx>
  • To: "programmingblind@xxxxxxxxxxxxx" <programmingblind@xxxxxxxxxxxxx>
  • Date: Sun, 28 Mar 2010 10:51:23 -0400

Hi,
I am kind of stumped here. I would like to watch a folder for new files
and import them automatically. I keep getting a syntax error even though
it seems like there aught not to be one lol. Anyway, here's the
misbehaving code, someone please help me take it out behind the wood
shed and teach it some manners. *grin*
#Dynamic Import section
customScripts = os.listdir("customizations")
for i in customScripts:
    exec("from customizations/" + i[:-3] + " import *")
#end dynamic import section
Thanks
Storm



-- 
Follow me on Twitter:
http://www.twitter.com/stormdragon2976
My blog, Thoughts of a Dragon:
http://www.stormdragon.us/
What color dragon are you?
http://quizfarm.com/quizzes/new/alustriel07/what-color-dragon-would-you-be/
Install Windows Vista in under 2 minutes:
http://is.gd/am6TD



Other related posts: