Message283220
Originally PEP 3101 defined the default __format__ implementation, object.__format__ as
def __format__(self, format_spec):
return format(str(self), format_spec)
After few changes (issue7994, issue28385) it now looks as
def __format__(self, format_spec):
assert format_spec == ''
return format(str(self), '')
Proposed patch makes it yet simpler:
def __format__(self, format_spec):
assert format_spec == ''
return str(self)
This is equivalent to the previous form except obscure case when str() returns not exact str, but strict subclass with overridden __format__.
The benefit of this change is simpler semantical model of the default implementation.
See the start of the discussion in issue28385 and the discussion on Python-Dev: https://mail.python.org/pipermail/python-dev/2016-October/146765.html. |
|
Date |
User |
Action |
Args |
2016-12-14 21:52:10 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, eric.smith |
2016-12-14 21:52:10 | serhiy.storchaka | set | messageid: <1481752330.56.0.847513688639.issue28974@psf.upfronthosting.co.za> |
2016-12-14 21:52:10 | serhiy.storchaka | link | issue28974 messages |
2016-12-14 21:52:10 | serhiy.storchaka | create | |
|