For the sake of knowledge, I would like to print the contents of the class attribute list all_contacts
of this code:
class Contact:
all_contacts = []
def __init__(self,name,email):
self.name = name
self.email = email
Contact.all_contacts.append(self)
However, all my attempts result in a memory address:
>>> c = Contact("Some Body", "somebody@example.net")
>>> c2 = Contact("Some Body 2", "somebody2@example.net")
>>> Contact.all_contacts
[<__main__.Contact object at 0x0000000002C8CF48>]
>>> print(Contact.all_contacts)
[<__main__.Contact object at 0x0000000002C8CF48>]
>>> c.all_contacts
[<__main__.Contact object at 0x0000000002C8CF48>]
How do I print this class attribute so I can see it's elements?