``` 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: [email protected] ICL/College Email: [email protected] On Tue, Nov 3, 2020 at 7:49 PM warp_drive enterprise <[email protected]> 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 -- [email protected] > To unsubscribe send an email to [email protected] > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/[email protected]/message/EHZMYYYNQUT667Q3WJKDZA35PUJ5TXFW/ > Code of Conduct: http://python.org/psf/codeofconduct/ >
_______________________________________________ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/LHDQ3MUC6IDWZHOYZHJVNQVGCI5U63D7/ Code of Conduct: http://python.org/psf/codeofconduct/
