I noticed a file include.txt
in every project I open. The file contains python code:
from aws_xray_sdk.core import patch_all
import sentry_sdk
from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration
# pragma: no cover
patch_all()
sentry_sdk.init(
dsn=...,
integrations=[AwsLambdaIntegration()]
)
That file is then being executed with execfile(os.path...+'/include.txt')
in multiple files within that project.
I'm sure the code is necessary. But why not name it include.py
and then import
it?
I have just recently joined the company, so I have asked a few people who have been around the longest, and nobody knows why.
I'm tempted to rename the txt
to py
and change execfile
to import
, but I'm worried that maybe there was a good reason for doing it that way. Possibly my change would appear to look fine but then have some distant unforeseen consequences.
So, is there ever a good reason put python code in a txt
file?
UPDATE:
We're using python 3.7.
Nothing from the include.txt
is mentioned anywhere else in the project code -- no references to sentry
or X-ray
.
In every module, execfile
is imported just before the call:
from past.builtins import execfile