I have a simple class in here:
class Info:
# __slots__ = ('name','age')
def __init__(self, name, age):
self.name = name
self.age = age
def members(self):
print(self.__dict__)
>>> Info(name= "John", age=10).members()
>>> {'name': 'John', 'age': 10}
Now, I add the __slot__
to the above class:
class Info:
__slots__ = ('name','age')
def __init__(self, name, age):
self.name = name
self.age = age
def members(self):
print(self.__dict__)
Info(name= "John", age=10).members()
Now, I keep getting the following error. How am I be able to access objects attributes in this case? Thanks!
print(self.__dict__)
AttributeError: 'Info' object has no attribute '__dict__'