[issue23479] str.format() breaks object duck typing

Martin Panter report at bugs.python.org
Wed Feb 18 23:07:56 CET 2015


Martin Panter added the comment:

My guess is you could make it work by adding a __format__ method to your custom class.

def __format__(self, format_spec):
    return format(float(self), format_spec)

----------
nosy: +vadmium

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23479>
_______________________________________


More information about the Python-bugs-list mailing list