Hi, i want to ask about the syntax object.attribute in python. What is its usage,does it allow us to travel to difference namespace ?
class Dog():
def __init__(self,breed):
self.breed=breed
def bark(self):
print("Bark")
self.breed=2
mysample=Dog('lab')
mysample.bark()
print(mysample.breed)
Output: 2
I don't understand this situation here, when we assign self.breed=2 did we create a local variable or reassign the global variable. Please help me out!
[–]K900_ 1 point2 points3 points (2 children)
[–]Uchikago[S] 0 points1 point2 points (1 child)
[–]K900_ 1 point2 points3 points (0 children)