The Python Oracle

importing a module in Idle shell

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Hypnotic Orient Looping

--

Chapters
00:00 Question
00:57 Accepted answer (Score 10)
01:23 Answer 2 (Score 9)
01:47 Answer 3 (Score -1)
02:06 Thank you

--

Full question
https://stackoverflow.com/questions/7971...

Accepted answer links:
[imp.loadmodule]: http://docs.python.org/library/imp.html

Answer 3 links:
[Loading (and unloading) Python modules]: http://blog.bfitz.us/?

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #python3x #pyc

#avk47



ACCEPTED ANSWER

Score 10


I don't think python modules are loaded I based on what you do with chdir. Modules are loaded from the folder you started the python shell and folders in PYTHONPATH.

If you want dynamically load modules maybe you can check imp.loadmodule (sample in the bottom of the page).




ANSWER 2

Score 9


you can add to the PYTHONPATH in code by doing

sys.path.append('<newpath'>)
from dfa import *

I don't believe changing your current directory has any impact on the import process and even if it did, I'm not sure that's how you would want to do it.