我注意到include.txt
我打开的每个项目中都有一个文件。该文件包含python代码:
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()]
)
execfile(os.path...+'/include.txt')
然后在该项目中的多个文件中执行该文件。
我确定代码是必要的。但为什么不命名它include.py
,然后import
呢?
我最近刚加入公司,所以问了几个在公司时间最长的人,没有人知道为什么。
我很想将 to 重命名txt
并py
更改execfile
为import
,但我担心这样做可能有充分的理由。可能我的更改看起来不错,但随后会产生一些不可预见的后果。
那么,是否有充分的理由将 python 代码放入txt
文件中?
更新:
我们正在使用python 3.7。
项目代码中的其他任何地方都没有include.txt
提及.sentry
X-ray
在每个模块中,execfile
在调用之前导入:
from past.builtins import execfile