This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author samuelcolvin
Recipients samuelcolvin
Date 2016-12-08.14:37:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1481207826.64.0.85637037523.issue28904@psf.upfronthosting.co.za>
In-reply-to
Content
(The "Components" selection might be wrong, I wasn't sure what to use)

As https://docs.python.org/3.6/library/string.html

> Three conversion flags are currently supported: '!s' which calls str() on the value, '!r' which calls repr() and '!a' which calls ascii().

It would be great if further conversation flags were added for more built-in methods. In particular:
* '!l' for len()
* '!i' for id()

(There might be others but these are the two I would find most useful.)

format() is now very powerful, but it's very common for strings, lists, dicts, sets etc. to want to include their length in strings. This is currently ugly.

This enhancement will be even more sought after with string literals in python 3.6.

Example of when this would be very useful:

v = {'type': 'whatever, 'items': ['foo', 'bar', 'spam']}
'{type}{items!l}'.format(**v)

Would also be very useful with getattr, and getitem usage.
History
Date User Action Args
2016-12-08 14:37:06samuelcolvinsetrecipients: + samuelcolvin
2016-12-08 14:37:06samuelcolvinsetmessageid: <1481207826.64.0.85637037523.issue28904@psf.upfronthosting.co.za>
2016-12-08 14:37:06samuelcolvinlinkissue28904 messages
2016-12-08 14:37:06samuelcolvincreate