Python文档似乎不清楚参数是通过引用还是值传递,以下代码生成未更改的值'Original'
class PassByReference:
def __init__(self):
self.variable = 'Original'
self.change(self.variable)
print(self.variable)
def change(self, var):
var = 'Changed'
Run Code Online (Sandbox Code Playgroud)
有什么我可以通过实际参考传递变量吗?
嗨,如果满足 if 语句的条件(在一段时间内满足),我正在尝试销毁一个类对象
global variablecheck
class createobject:
def __init__(self,userinput):
self.userinput = input
self.method()
def method(self):
while True:
if self.userinput == variablecheck
print('the object created using this class is still alive')
else:
print('user object created using class(createobject) is dead')
#what code can i put here to delete the object of this class?
Run Code Online (Sandbox Code Playgroud)