Running a python script from interactive mode

Chris Rebert clp2 at rebertia.com
Wed Nov 18 00:10:23 EST 2009


On Tue, Nov 17, 2009 at 8:56 PM, ashwini yal <ashwiniyal at gmail.com> wrote:
> Hi,
>
> I am trying to run a python script from interactive mode ,but i am not able
> to know how to run it? Is it possible? if yes please let me how to run the
> script?

execfile("/path/to/the/script.py")

or if it's on your sys.path
and doesn't use the `if __name__ == "__main__":` idiom
then just importing it works:

import script_name

Cheers,
Chris
--
http://blog.rebertia.com



More information about the Python-list mailing list