I just want to ask if I can assign an instance of a class to itself in a method.
For example, is the following valid python code?
class O(object):
def __init__(self,value):
self.value = value
def do_something(self):
self = O(1)
Does this lead to any unexpected behaviour?
Obviously, the code can be run. But when I do
A = O(2)
A.do_something()
A.value
the output is 2
, when I expect it to be 1
.