i have a class for lists that creates list objects and deals with list actions, and i have another class 'Dog' to create Dog objects. However, i can´t manage to print the atributes of class 'Dog'(name and age)after appending an object of type 'Dog' to a list of type 'Dogslist'. Instead by printing the list it prints the addresses of the objects. How can i print name and age of all the dogs i have in the list?
class Dogslist():
def __init__(self):
self.lista = []
def append(self, object):
self.lista.append(object)
def delete(self):
pass
def showlist(self):
pass
class Dog:
def __init__(self, name, age):
self.__name = name
self.__age = age
def description(self):
return self.__name, self.__age
a=Dog("Geralt", 10)
b=Dog("Vesemir", 13)
doglist = Dogslist()
doglist.append(a)
doglist.append(b)
print(doglist.lista)
The output shows the following wich refers to objects' addresses:
[<__main__.Dog object at 0x7f25ed30c0a0>, <__main__.Dog object
at 0x7f25ed2f18b0>]