Problem
How do I compare an object made from a class to a string? I've added multiple objects to a list. When I loop through the list:
for i in self._list:
print(i)
It prints out this:
<sokker.Sokker object at 0x019E9A30>
Problem
How do I compare an object made from a class to a string? I've added multiple objects to a list. When I loop through the list:
for i in self._list:
print(i)
It prints out this:
<sokker.Sokker object at 0x019E9A30>
From what I can see, you want to print an object. You can use string to do that using:
list_of_objects = [my_object_one, my_object_two]
for object in list_of_objects:
print(str(object))
It will call the __str__()
of the object
class and hopefully display the information you wish to see.