Can I load a python program at the interactive >>> prompt?

Brian Blais bblais at bryant.edu
Fri Dec 5 16:37:37 EST 2008


On Dec 5, 2008, at 15:52 , walterbyrd wrote:

> Can I load a file into the python interactive environment?  For
> example I have a file called test.py that consists of the following:
>
> print "hello"
> print "hello again"
>
> Can I load that file into python at the >>> prompt?
>
>>>> load "test.py"
>
> or something like that?
>

I think you mean:

execfile('test.py')

that should work.  if you have iPython, which is a great shell for  
running python code, you can do:

run test.py

as far as copy/paste, I think in Windows Python runs in a DOS prompt,  
so you should be able to right-click and choose Edit/Paste.  Not too  
convenient, but I think it works.


			bb



-- 
Brian Blais
bblais at bryant.edu
http://web.bryant.edu/~bblais



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20081205/0ae78352/attachment-0001.html>


More information about the Python-list mailing list