xbmuncher wrote:
I have a script called: script.py and here are the contents:
h = open('file2.dat', 'rb')
data = h.read(1120)
h.close()
print(data)
input("Press ENTER to exit")
I am editing it in Notepad++ and I set it up so I can run in on
python.exe (I have python30) from the program, it sends these parameters:
C:\Python30\python.exe pathToFile\folder\script.py
Well when I run the script via this method, the screen flashes and
quickly disappears, so there must be some kind of error. I used screen
capture to try to capture what happened so I can read the message,
this is what I got:
Traceback (most recent call last):
File "C:\path to file\script.py", line 1, in
<module>
h = open('file2.dat', 'rb')
File "C:\Python30\lib\io.py", line 278, in __new__
return open(*(args, **kwargs)
File "C:\Python30\lib\io.py", line 222, in open
closefd)
File "C:\Python30\lib\io.py", line 619, in __init__
The WEIRD thing is, is that I can double click the same unchanged
script.py file and it will run from the same program python.exe and it
will display this output:
\xb7\lots of these types of \xb codes
Press ENTER to exit
So my question is, why does it have different output run from the same
python.exe program when the script remains the same. I'd like to
called it to run from notepad++ out of convenience just as it runs
when I double click on it.. but i'm getting different behavior and I
dont know why...
Maybe I can turn off traceback info?
My guess is when you run from N++ there is a different current directory
than when using dblclk. Run following script to verify that:
import os
print(os.getcwd())
--
Bob Gailer
Chapel Hill NC
919-636-4239
_______________________________________________
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor