Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue28974

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:Make default __format__ be equivalent to __str__
Type:enhancementStage:resolved
Components:Interpreter CoreVersions:Python 3.7
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To:Nosy List: eric.smith, rhettinger, serhiy.storchaka
Priority:normalKeywords:patch

Created on2016-12-14 21:52 byserhiy.storchaka, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.

Files
File nameUploadedDescriptionEdit
simpler-object-__format__.patchserhiy.storchaka,2016-12-14 21:52review
Pull Requests
URLStatusLinkedEdit
PR 506mergedserhiy.storchaka,2017-03-06 09:53
Messages (4)
msg283220 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2016-12-14 21:52
OriginallyPEP 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 inissue28385 and the discussion on Python-Dev:https://mail.python.org/pipermail/python-dev/2016-October/146765.html.
msg293605 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2017-05-13 08:36
What are your thoughts about this Eric?
msg293607 -(view)Author: Eric V. Smith (eric.smith)*(Python committer)Date: 2017-05-13 09:08
I'm okay with this change.
msg293609 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2017-05-13 09:40
New changeset7e19dbc92ec06a987eaae72f7cdfd32006aa4960 by Serhiy Storchaka in branch 'master':bpo-28974: `object.__format__(x, '')` is now equivalent to `str(x)` (#506)https://github.com/python/cpython/commit/7e19dbc92ec06a987eaae72f7cdfd32006aa4960
History
DateUserActionArgs
2022-04-11 14:58:40adminsetgithub: 73160
2017-05-13 09:41:23serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2017-05-13 09:40:54serhiy.storchakasetmessages: +msg293609
2017-05-13 09:08:03eric.smithsetmessages: +msg293607
2017-05-13 08:36:34serhiy.storchakasetmessages: +msg293605
2017-03-06 09:57:34rhettingersetnosy: +rhettinger
2017-03-06 09:53:17serhiy.storchakasetpull_requests: +pull_request415
2016-12-14 21:52:10serhiy.storchakacreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp