I have some questions when it comes to classes and OOP in general.
# Lets say we have this variable.
my_integer = 15
Now, if I got it right, when assignment occurs, Python creates an object of the int class with the value of 15 which is then referenced by the name-tag defined as my_integer.
# Now we "change" it.
my_integer = 50
This SHOULD now create a new int object with the value of 50 but the reference tag switches to the newly created object, thus leaving the one with 15 without a tag and up for garbage disposal.
class Point:
"""Point class represents and manipulates x,y coords."""
def __init__(self):
self.x = 0
self.y = 0
one = Point()
two = Point()
one.x = 50
two.y = 150
When I create those Point() objects with the attributes x and y, does Python basically create an integer object inside the Point() object?
Doesn't it get kinda complicated like that when there are multiple objects inside an object?
Is my understanding in the first two points correct?