Nick Coghlan wrote: > Filip GruszczyĆski wrote: >> I would appreciate any advice on this topic, even if this ticket would >> be dismissed altogether, as I would like to learn as much as possible >> on practices on developing Python. > > Raymond's use case is valid, but the currently proposed method name is > way too long to be usable and the use of *args is a definite misfeature. > > I suggest approaching the issue with the exact spec needed to cover the > problem Raymond described: > > Add a method to strings that allows a format string to > be applied to an existing mapping without implicitly > converting the mapping to a dict first. It occurs to me that Raymond's use case could be satisfied using existing Python, by slightly changing the format string. After all, str.format() supports mapping lookup already: $ ./python.exe Python 2.6.5+ (release26-maint:79421, Mar 25 2010, 08:51:39) [GCC 4.2.1 (Apple Inc. build 5646) (dot 1)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> class Default(dict): ... def __missing__(self, key): ... return key ... >>> s = '{m[name]} was born in {m[country]}' >>> s.format(m=Default(name='Guido')) 'Guido was born in country' >>> Considering that, maybe the best thing is to do nothing. I'll update the issue with this note. -- Eric.
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