9 The Official TELTUB Blog
Saturday, October 31, 2009
A workaround solution to python str/repr issue
Remember my post about the python __str__ issue? A couple of people asked me if I had any simple patch/workaround for it. Here is a small function that you can use to work around the problem (click on the Show code to see the solution):

Click here to show the code

Here is a nice example of the solution:
  >>> from decimal import Decimal
>>> from datetime import datetime
>>> str([Decimal('42'), datetime.now()])
'[Decimal("42"), datetime.datetime(2009, 11, 1, 23, 47, 47, 45115)]'
>>> my_str([Decimal('42'), datetime.now()])
'[42,2009-11-01 23:47:51.517091]'