Skip to main content
added 91 characters in body
Source Link
codeape
  • 101.5k
  • 26
  • 180
  • 201

For Python 2:

>>> execfile('filename.py') 

For Python 3:

>>> exec(open("filename.py").read()) # or >>> from pathlib import Path >>> exec(Path("filename.py").read_text()) 

See the documentation. If you are using Python 3.0, see this question.

See answer by @S.Lott for an example of how you access globals from filename.py after executing it.

For Python 2:

>>> execfile('filename.py') 

For Python 3:

>>> exec(open("filename.py").read()) 

See the documentation. If you are using Python 3.0, see this question.

See answer by @S.Lott for an example of how you access globals from filename.py after executing it.

For Python 2:

>>> execfile('filename.py') 

For Python 3:

>>> exec(open("filename.py").read()) # or >>> from pathlib import Path >>> exec(Path("filename.py").read_text()) 

See the documentation. If you are using Python 3.0, see this question.

See answer by @S.Lott for an example of how you access globals from filename.py after executing it.

For Python 2:

>>> execfile('filename.py') 

For Python 3:

>>> exec(open("filename.py").read()) 

See the documentation. If you are using Python 3.0, see this question.

See answer by @S.Lott for an example of how you access globals from filename.py after executing it.

>>> execfile('filename.py') 

See the documentation. If you are using Python 3.0, see this question.

See answer by @S.Lott for an example of how you access globals from filename.py after executing it.

For Python 2:

>>> execfile('filename.py') 

For Python 3:

>>> exec(open("filename.py").read()) 

See the documentation. If you are using Python 3.0, see this question.

See answer by @S.Lott for an example of how you access globals from filename.py after executing it.

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot
>>> execfile('filename.py') 

See the documentation. If you are using Python 3.0, see this questionthis question.

See answer by @S.Lott for an example of how you access globals from filename.py after executing it.

>>> execfile('filename.py') 

See the documentation. If you are using Python 3.0, see this question.

See answer by @S.Lott for an example of how you access globals from filename.py after executing it.

>>> execfile('filename.py') 

See the documentation. If you are using Python 3.0, see this question.

See answer by @S.Lott for an example of how you access globals from filename.py after executing it.

reference to S.Lott's answer.
Source Link
codeape
  • 101.5k
  • 26
  • 180
  • 201
Loading
Source Link
codeape
  • 101.5k
  • 26
  • 180
  • 201
Loading