Same Address, Borrowed Later
This runs under CPython.
class Point:
__slots__ = ("x", "y")
def __init__(self, x, y):
self.x = x
self.y = y
a = Point(1, 1)
b = Point(2, 2)
print(id(a) == id(b))
c = Point(3, 3)
id_c = id(c)
del c
d = Point(4, 4)
print(id(d) == id_c)
What do the two print calls output?
Sign in to answer questions and track your progress
Sign In