I'm writing a class in Python and I'm writing a __str__()
function so my print statements can print string representations of instances of that class. Is there ever a reason to directly do something like this:
myObj = Foo(params)
doSomething(myObj.__str__())
It feels like since there are other neater ways to do this, it would be a bad idea (or at least, not proper style) to directly call __str__()
. That said, I can't find a website specifically saying not to.