G
George Burdell
My understanding is that any object which is not pointed to by any
variable will be automatically deleted. What if I create a class
object, but only keep a reference to one of its members, and not a
reference to the object itself? What goes on internally in Python?
Does Python retain the whole object, or does it just keep a copy of
the referenced member?
For example, if I have
def myclass:
def __init__(self):
self.x = [1,2,3]
self.y = [4,5,6]
x = myclass().x
This works, and I correctly get x = [1,2,3]. But what happened to the
myclass() object initially created, and the member "y"?
variable will be automatically deleted. What if I create a class
object, but only keep a reference to one of its members, and not a
reference to the object itself? What goes on internally in Python?
Does Python retain the whole object, or does it just keep a copy of
the referenced member?
For example, if I have
def myclass:
def __init__(self):
self.x = [1,2,3]
self.y = [4,5,6]
x = myclass().x
This works, and I correctly get x = [1,2,3]. But what happened to the
myclass() object initially created, and the member "y"?