New guy question

Nick Perkins nperkins7 at home.com
Sun Jun 10 01:49:44 EDT 2001


..of course you can also run your program from the >>> prompt:
( in addition to Alex's suggestion:  >>>execfile('alook.py')  )

>>> import alook

..will effectively 'run' your program.
( actually it loads it into the current namespace, -- more or less the same
thing)
( note that you leave of the .py extension )
The file alook.py must be on the sys.path -- another issue )

..but the next time you will have to type:

>>> reload(alook)

.. because Python will not import the same thing twice,
even if the file has changed.




"D-Man" <dsh8290 at rit.edu> wrote in message
news:mailman.992138655.8349.python-list at python.org...
> On Sat, Jun 09, 2001 at 11:28:51PM +0000, Glen Mettler wrote:
> | I have a small script I entered from a Python book that works when I run
it
> | using F5.
> | However, when I go to the console and enter python alook.py, I get an
error
> | message:
> |
> | >>> python alook.py
> | SyntaxError: invalid syntax
> |
> | I am too new to this to know why.
>
> As Alex indicated, it is not a problem with understanding python.  I
> have seen that "new" Wintel-PC users often don't know what a shell is.
> A "shell" is a prompt provided by the OS to enter commands.  On
> "Wintel" boxes it used to be called DOS.  Now it is either called
> "MS-DOS Prompt" or "Command Prompt" and can be found under the Start
> menu.  On a Unix system their are many different shells, and the shell
> is the first thing you will learn.  A shell is where you would type
> things like "cd" "copy" "del", etc.  There you can type "python
> alook.py" (assuming alook.py is in the current directory) to run the
> program.  The prompt (for a DOS shell) is "C:\>" or something similar.
>
> You have the "Python Interactive Interpreter" there, indicated by the
> ">>>" prompt.  In this shell-like window you can enter python
> statements only.  No OS commands are allowed because they aren't
> python code.
>
> If you have any more questions re shells and DOS/Windows feel free to
> ask.  You may also be interested in the "Tutor" list,
> tutor at python.org.
>
> HTH,
> -D
>
>





More information about the Python-list mailing list