[英]Passing a variable through a class Python
I am trying to print to pass the endpoint
variable to the __init__
function within the RUN()
class.我正在尝试打印以将
endpoint
变量传递给RUN()
class 中的__init__
function。 However it is giving me an error.但是它给了我一个错误。
AttributeError: module 'configs' has no attribute 'endpoint'
. AttributeError: module 'configs' has no attribute 'endpoint'
。 The endpoint document is saved in the file1.py
and it is called in file2.py
.端点文档保存在
file1.py
中,并在file2.py
中调用。 How would I be able to pass endpoint as a param.我如何能够将端点作为参数传递。
file1文件 1
endpoint = 'hello'
file2文件2
import file1
class RUN():
def __init__(self, endpoint= file1.endpoint):
print("Initialized")
run_websocket = RUN()
The code is absolutely correct.代码绝对正确。 Try deleting the cache of your IDE or build and dist folders, etc. then run again.
尝试删除 IDE 或 build 和 dist 文件夹等的缓存,然后再次运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.