New submission from Serhiy Storchaka: 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. ---------- components: Interpreter Core files: simpler-object-__format__.patch keywords: patch messages: 283220 nosy: eric.smith, serhiy.storchaka priority: normal severity: normal stage: patch review status: open title: Make default __format__ be equivalent to __str__ type: enhancement versions: Python 3.7 Added file: http://bugs.python.org/file45902/simpler-object-__format__.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28974> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com