How can I run a program?

L

Lad

Hello,
I am running Python on XP and have a problem with
a program if its name consists '-' for example:
my-program.py
When I try to run a program with such name
I get the error :

Traceback (most recent call last):
File "<interactive input>", line 1, in ?
NameError: name 'my' is not defined

Python thinks that the name of program is my.py only
but the name is my-program.py

What is a solution?
Thank you
Lad.
 
T

Thorsten Kampe

* Lad (2005-07-30 11:33 +0100)
I am running Python on XP and have a problem with
a program if its name consists '-' for example:
my-program.py
When I try to run a program with such name

/How/ do you "run" the program for Guido's sake?!
I get the error :

Traceback (most recent call last):
File "<interactive input>", line 1, in ?
NameError: name 'my' is not defined

Python thinks that the name of program is my.py only
but the name is my-program.py

What is a solution?

The solution to get answers is to give details.

But to play the clairvoyant:

/If/ you tried to run the program from a command prompt or from by
klicking on the file there should be no problems.

/If/ you tried to run the program by importing it from the Python
shell, then this is normal. A hyphen is not allowed in module names at
it is the same character as in subtractation.
 
P

phil hunt

Hello,
I am running Python on XP and have a problem with
a program if its name consists '-' for example:
my-program.py
When I try to run a program with such name
I get the error :

Traceback (most recent call last):
File "<interactive input>", line 1, in ?
NameError: name 'my' is not defined

Python thinks that the name of program is my.py only
but the name is my-program.py

What is a solution?

Have you tried renaming it so it doesn't have a "-" in it?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,152
Latest member
LorettaGur
Top