in a code example on this site i saw the following code example:
class Robot:
__counter = 0
def __init__(self):
type(self).__counter += 1
def RobotInstances():
return Robot.__counter
The __init__
method in the example above is incrementing the __counter
whenever the class is instantiated.
My question is: Since type(self)
is supposed to return the type of an object, can it also be assigned to?