```
import myfile
```
or
```
from myfile import *
```
Will import the names from another file. You should use this instead of
executing text read from a path.
Thanks,
----
*Cade Brown*
Research Assistant @ ICL (Innovative Computing Laboratory)
Personal Email: brown.cade@gmail.com
ICL/College Email: cade@utk.edu
On Tue, Nov 3, 2020 at 7:49 PM warp_drive enterprise
I have recently have the opportunity to work on a Python web application. I've found it beneficial to reduce duplicate code with the following code lines
import textwrap from pathlib import Path exec(textwrap.dedent(Path('myfile.py').read_text()))
Perhaps such code could be the basis for a python_include() statement similar to how includes, requires work in PHP.
Thank you for any consideration. _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/EHZMYY... Code of Conduct: http://python.org/psf/codeofconduct/