Eric V. Smith <e...@trueblade.com> added the comment:
About translating ":s" to "": > The library seems willing to do this for the empty format string, but not when the client code specifically asks for a string.... You're not asking for a string when you specify ":s". You're asking the object to interpret "s" however it wants. For example, if the object is a datetime, you're asking for the output to be "s": >>> f'{datetime.datetime.now():s}' 's' versus: >>> f'{datetime.datetime.now()}' '2018-08-22 10:27:25.188891' It's precisely because we want to let the object interpret the string that Python no longer guesses as to what you might mean. For example, say you have a MyDate object, that doesn't support __format__, and you want Python to decide that format(MyDate(), 's') means is the same as format(MyDate(), ''). But later you decide that you want the format strings to call strftime (like datetime does). You couldn't do that without breaking existing usage of your library. This actually happened with complex when I added complex.__format__. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue34425> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com