Newby Python Programming Question
Coyote
sageandecho at gmail.com
Fri May 11 11:25:20 EDT 2012
Folks,
I am migrating to Python after a 20+ year career writing IDL programs exclusively. I have a really simple question that I can't find the answer to in any of the books and tutorials I have been reading to get up to speed.
I have two programs. The first is in a file I named file_utils.py:
def pwd():
import os
print os.getcwd()
The second is in a file I named pwd.py:
import os
print os.getcwd()
Here is my question. I am using the Spyder IDE to run these programs. If I type these commands, I get exactly what I want, the name of my current directory:
>>>from file_utils import pwd
>>>pwd()
C:\Users\coyote\pyscripts
But, if I "run" the pwd.py script by selecting the "Run" option from the IDE menu, the directory is printed *twice* in the output window. Why is that?
Thanks!
Cheers,
David
More information about the Python-list
mailing list