Let's say I have a class
class A:
def method(self):
return self
If method
is called, is a pointer to the A
-object going to be returned, or a copy of the object?
Let's say I have a class
class A:
def method(self):
return self
If method
is called, is a pointer to the A
-object going to be returned, or a copy of the object?
It returns a reference:
You can think of it this way: You actually pass
self
to the.method()
function as an argument and it returns the sameself
.It returns a reference to the object, look at the following example:
About the
id
function (from python docs):