Use case is simple: I create an object from a class in Python. If I create that object outside of any function, I have no problem getting back any of the attributes.
But somehow if I happened to create that object inside a function, I cannot get it back anywhere.
This works:
class UserTest():
def__init__(self,name,age,size):
self.name=name
self.age=age
self.size=size
FirstUser=UserTest(name,age,size)
print(FirstUser.name,FirstUser.age,FirstUser.size)
But this does not:
class UserTest():
def__init__(self,name,age,size):
self.name=name
self.age=age
self.size=size
def createUser(name,age,size):
FirstUser=Usertest(name,age,size)
return FirstUser
createUser('Max',38,180)
print(FirstUser.name,FirstUser.age,FirstUser.size)
And I cannot figure why I cannot find the object I just created, even if I return the FirstUser object at the end of the function. What am I missing?