Author serhiy.storchaka
Recipients eric.smith, serhiy.storchaka
Date 2016-12-14.21:52:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1481752330.56.0.847513688639.issue28974@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2016-12-14 21:52:10serhiy.storchakasetrecipients: + serhiy.storchaka, eric.smith
2016-12-14 21:52:10serhiy.storchakasetmessageid: <1481752330.56.0.847513688639.issue28974@psf.upfronthosting.co.za>
2016-12-14 21:52:10serhiy.storchakalinkissue28974 messages
2016-12-14 21:52:10serhiy.storchakacreate