Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #45516
| From | Terry Jan Reedy <tjreedy@udel.edu> |
|---|---|
| Subject | Re: how to run another file inside current file? |
| Date | 2013-05-18 12:39 -0400 |
| References | <67c4dd92-7e6a-4955-850b-0c21c2708e05@googlegroups.com> <CAG=aD5aMmunaqXzdP9eUiTg6uQvBjny0xxAbXMD5DCP9-zTocg@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1807.1368895205.3114.python-list@python.org> (permalink) |
On 5/18/2013 7:15 AM, Kevin Xi wrote:
> Hi,
> It's better to specify version of python you work with.
Absolutely.
I know nothing
> about python 3 but in python 2 you can do this with `exec`. Example:
>
> > f = file('otherFile.py')
> > exec f
Py 2 has execfile that does the above. Py 3 do as above except that exec
is a function.
with open('otherfile.py') as f:
exex(f)
> For more, read the doc:
> http://docs.python.org/2.7/reference/simple_stmts.html#the-exec-statement
> HTH
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
how to run another file inside current file? Avnesh Shakya <avnesh.nitk@gmail.com> - 2013-05-17 21:48 -0700 Re: how to run another file inside current file? Kevin Xi <kevin.xgr@gmail.com> - 2013-05-18 19:15 +0800 Re: how to run another file inside current file? Terry Jan Reedy <tjreedy@udel.edu> - 2013-05-18 12:39 -0400
csiph-web