On Thu, 5 Jun 2008 10:43:20 pm Nick Coghlan wrote: > I'm really starting to wonder if supporting positional arguments to > str.format() *at all* is a mistake. Maybe we should ditch support for > positional arguments and just accept a single dictionary as the sole > parameter to format(). > > For dictionary formatting, str.format() is a clear winner over > str.__mod__(). For positional formatting I'm not so sure - if someone > decided to convert from %-formatting to str.format, would it be such > a burden to ask them to name their substitution variables in the > process? If positional arguments are dropped, I would expect to see a proliferation of meaningless names used in the dicts: "items {a} {b}".format(dict(a=spam, b=eggs)) In other words, the names will be just aliases for the position. I would also expect a performance hit. On my computer, dict(a=spam, b=eggs) is two times slower than {'a':spam, 'b':eggs} and nearly three times slower than (spam, eggs). I don't imagine building a dict will ever be faster than building a tuple. Given that format() is already significantly slower than %, why make it slower still? -1 on dropping positional arguments. -- Steven
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4