Python command line?
Steve Holden
sholden at holdenweb.com
Tue Jun 4 12:16:51 EDT 2002
"SA" <sarmstrong13 at mac.com> wrote in message
news:B9224E06.628B%sarmstrong13 at mac.com...
> Hi Everyone-
>
> I would like to run python code line by line using:
>
> python -c some line of code
>
> Will this work?
>
No. Sorry. Every time you run python you will get a completely new
environemnt which has no memory of what previous invocations have done. Like
this:
$ python -c "myvar = 21"
$ python -c "print myvar"
Traceback (most recent call last):
File "<string>", line 1, in ?
NameError: name 'myvar' is not defined
> I have a gui app that lets me type in code in one fiels and then executes
> the code typed into that field line by line and prints the output to
another
> field for evaluation.
>
That's good, b ut you are going to have to go a little further to get what
you want. Of course, IDLE and PythonWin do this already, so at least there's
a body of Python source for you to read.
regards
-----------------------------------------------------------------------
Steve Holden http://www.holdenweb.com/
Python Web Programming http://pydish.holdenweb.com/pwp/
-----------------------------------------------------------------------
More information about the Python-list
mailing list