working with classes, inheritance, _str_ returns and a list
Frank Millman
frank at chagford.com
Mon Jan 16 00:25:59 EST 2017
"David D" wrote in message
news:4f0680eb-2678-4ea2-b622-a6cd5a19e0a0 at googlegroups.com...
>
> I am creating a parent class and a child class. I am inheriting from the
> parent with an additional attribute in the child class. I am using
> __str__ to return the information. When I run > the code, it does exactly
> what I want, it returns the __str__ information. This all works great.
>
> BUT
>
> 1) I want what is returned to be appended to a list (the list will be my
> database)
> 2) I append the information to the list that I created
> 3) Whenever I print the list, I get a memory location
>
You have been given an explanation, and a couple of workarounds.
Here is another possible workaround, which may help depending on how you
actually print the list -
If you are saying -
for item in list:
print(item)
you can say instead -
for item in list:
print(str(item))
HTH
Frank Millman
More information about the Python-list
mailing list