Help:What does this mean?

K

kr

Hello,
I am new to PytonWin. I have a simple script, just one line-- print "hello".
It runs OK when I use File/Run
But in command lineI got the error msg:
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
NameError: name 'Script1' is not defined

What's wrong with it? How can I fix it?
THKS
kr
 
R

Ryan Paul

Hello,
I am new to PytonWin. I have a simple script, just one line-- print "hello".
It runs OK when I use File/Run
But in command line
I got the error msg:
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
NameError: name 'Script1' is not defined

What's wrong with it? How can I fix it?
THKS
kr

import Script1

--segphault
 
L

Lee Harr

Hello,
I am new to PytonWin. I have a simple script, just one line-- print "hello".
It runs OK when I use File/Run
But in command line
I got the error msg:
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
NameError: name 'Script1' is not defined

What's wrong with it? How can I fix it?
THKS
kr


That is not a "command line" per se. It is the "interactive interpreter"

By typing

Script1.py

You are asking the interpreter to find an object called "Script1" and
then find the "py" attribute of that object... kind of like this:
.... def __init__(self, pyosity):
.... self.py = pyosity
....'mega'


On the other hand, if you have saved a python script in a file
called Script1.py and you want to run that script from the
interactive interpreter you can (as someone else pointed out)

import Script1


Most likely, you will want to create functions in your module
instead of just having a script, so that you could do something
more along the lines of

import Script1
Script1.main()
 

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
474,201
Messages
2,571,047
Members
47,646
Latest member
xayaci5906

Latest Threads

Top