Help:What does this mean?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kr

    Help:What does this mean?

    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[color=blue][color=green]
    >> Script1.py[/color][/color]
    I got the error msg:
    Traceback (most recent call last):
    File "<interacti ve input>", line 1, in ?
    NameError: name 'Script1' is not defined

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


  • Ryan Paul

    #2
    Re: Help:What does this mean?

    On Wed, 26 May 2004 05:18:18 +0800, kr wrote:
    [color=blue]
    > 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[color=green][color=darkred]
    >>> Script1.py[/color][/color]
    > I got the error msg:
    > Traceback (most recent call last):
    > File "<interacti ve input>", line 1, in ?
    > NameError: name 'Script1' is not defined
    >
    > What's wrong with it? How can I fix it?
    > THKS
    > kr[/color]

    import Script1

    --segphault

    Comment

    • Lee Harr

      #3
      Re: Help:What does this mean?

      On 2004-05-25, kr <kr9999@sinamai l.com> wrote:[color=blue]
      > 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[color=green][color=darkred]
      >>> Script1.py[/color][/color]
      > I got the error msg:
      > Traceback (most recent call last):
      > File "<interacti ve input>", line 1, in ?
      > NameError: name 'Script1' is not defined
      >
      > What's wrong with it? How can I fix it?
      > THKS
      > kr
      >
      >[/color]


      That is not a "command line" per se. It is the "interactiv e 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:
      [color=blue][color=green][color=darkred]
      >>> class PyScript:[/color][/color][/color]
      .... def __init__(self, pyosity):
      .... self.py = pyosity
      ....[color=blue][color=green][color=darkred]
      >>> Script1 = PyScript('mega' )
      >>>
      >>> Script1.py[/color][/color][/color]
      '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()


      Comment

      Working...