First off, i apologize for the badly named thread... I tried to edit the name, but for some reason the new name won't update...
Ok, so i'm new to python.. but i've undertaken a project in python, and i have to see it through...
So far i'm having two persistant problems...
1. If i have a python script, called for example prog.py, if i try running it in the terminal, or in DOS as 'python prog.py' it runs perfectly (well, in most cases). However if i run 'prog.py' in a python shell, i get the following error
Traceback (most recent call last):
File "<interacti ve input>", line 1, in <module>
NameError: name 'prog' is not defined
My code is
#!C:/Python25
#Filename prog.py
fileobj=open('C :/Python25/user progs/testtext.txt',' r')
fileobj.read()
2. Regarding the fileobj.read()
If i type the two commands
ie: fileobj=open('C :/Python25/user progs/testtext.txt',' r')
fileobj.read()
separately in the shell, i get the expected output. However, when i run the script in the command terminal, (as above: 'python prog.py' ) it does not give me any errors, however it does not display the contents of the file....
Can anyone lead me in the right direction please?
Ok, so i'm new to python.. but i've undertaken a project in python, and i have to see it through...
So far i'm having two persistant problems...
1. If i have a python script, called for example prog.py, if i try running it in the terminal, or in DOS as 'python prog.py' it runs perfectly (well, in most cases). However if i run 'prog.py' in a python shell, i get the following error
Traceback (most recent call last):
File "<interacti ve input>", line 1, in <module>
NameError: name 'prog' is not defined
My code is
#!C:/Python25
#Filename prog.py
fileobj=open('C :/Python25/user progs/testtext.txt',' r')
fileobj.read()
2. Regarding the fileobj.read()
If i type the two commands
ie: fileobj=open('C :/Python25/user progs/testtext.txt',' r')
fileobj.read()
separately in the shell, i get the expected output. However, when i run the script in the command terminal, (as above: 'python prog.py' ) it does not give me any errors, however it does not display the contents of the file....
Can anyone lead me in the right direction please?
Comment