``` 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.c...@gmail.com ICL/College Email: c...@utk.edu On Tue, Nov 3, 2020 at 7:49 PM warp_drive enterprise <robo...@gmail.com> wrote: > 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-le...@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/EHZMYYYNQUT667Q3WJKDZA35PUJ5TXFW/ > Code of Conduct: http://python.org/psf/codeofconduct/ >
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@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/LHDQ3MUC6IDWZHOYZHJVNQVGCI5U63D7/ Code of Conduct: http://python.org/psf/codeofconduct/