Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #72168
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Subject | Re: How to run script from interpreter? |
| Date | 2014-05-28 11:32 -0400 |
| References | <mailman.979847065.10000.python-list@python.org> <6e96c4c4-17db-464b-b291-816c534b70c4@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.10405.1401291154.18130.python-list@python.org> (permalink) |
On 5/28/2014 3:44 AM, onlyvinish@gmail.com wrote: > On Friday, January 19, 2001 1:22:23 AM UTC+5:30, Rolander, Dan wrote: >> What is the best way to run a python script from within the interpreter? >> What command should I use? >> >> Thanks, >> Dan > > try using execfile(filename) or in 3.x with open(filename) as f: exec f These both assume that you want to run the script in the same process as the interpreter and within the module containing the statement. This is rare. People usually either want to import into a separate module or run in a separate process. For the latter, use the subprocess module and the same command line that you would use in a console. -- Terry Jan Reedy
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: How to run script from interpreter? onlyvinish@gmail.com - 2014-05-28 00:44 -0700
Re: How to run script from interpreter? Terry Reedy <tjreedy@udel.edu> - 2014-05-28 11:32 -0400
Re: How to run script from interpreter? Mark H Harris <harrismh777@gmail.com> - 2014-05-28 11:39 -0500
Re: How to run script from interpreter? Steven D'Aprano <steve@pearwood.info> - 2014-05-29 03:22 +0000
Re: How to run script from interpreter? Mark H Harris <harrismh777@gmail.com> - 2014-05-29 15:26 -0500
Re: How to run script from interpreter? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-30 00:33 +0000
Re: How to run script from interpreter? Chris Angelico <rosuav@gmail.com> - 2014-05-30 10:46 +1000
Re: How to run script from interpreter? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-30 01:49 +0000
Re: How to run script from interpreter? Chris Angelico <rosuav@gmail.com> - 2014-05-30 12:04 +1000
Re: How to run script from interpreter? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-30 06:20 +0000
Re: How to run script from interpreter? Chris Angelico <rosuav@gmail.com> - 2014-05-30 17:19 +1000
Re: How to run script from interpreter? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-30 11:27 +0000
Re: How to run script from interpreter? Chris Angelico <rosuav@gmail.com> - 2014-05-30 21:46 +1000
Re: How to run script from interpreter? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-30 19:28 +0000
Re: How to run script from interpreter? Chris Angelico <rosuav@gmail.com> - 2014-05-31 05:47 +1000
Re: How to run script from interpreter? Terry Reedy <tjreedy@udel.edu> - 2014-05-30 11:24 -0400
csiph-web