Help:What does this mean?

Lee Harr missive at frontiernet.net
Wed May 26 16:19:38 EDT 2004


On 2004-05-25, kr <kr9999 at sinamail.com> wrote:
> 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
>>> Script1.py
> 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:

>>> class PyScript:
...     def __init__(self, pyosity):
...         self.py = pyosity
...
>>> Script1 = PyScript('mega')
>>>
>>> Script1.py
'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()





More information about the Python-list mailing list