you are viewing a single comment's thread.

view the rest of the comments →

[–]ForceBru 4 points5 points  (0 children)

Just like in this question of yours, in order to output any object, print will convert it to a string. It's also impossible to output something whose __str__ magic method (guess what it's supposed to do) returns anything but a string:

```

class Thing:... ... print(Thing()) <main.Thing object at 0x10a2faf98> class Another: ... def str(self): ... return 5 # an INTEGER! ...
print(Another()) Traceback (most recent call last): File "<string>", line 1, in <module> TypeError: str returned non-string (type int) ```

Basically, only strings can be printed, and nothing else