Author eric.smith
Recipients ebehar, eric.smith, ezio.melotti, gruszczy, r.david.murray, rhettinger
Date 2010-03-25.13:00:18
SpamBayes Score 8.36949e-07
Marked as misclassified No
Message-id <1269522020.6.0.3927200936.issue6081@psf.upfronthosting.co.za>
In-reply-to
Content
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. Or maybe update the documentation with this example.

Plus, you could mix and match this with *args as you'd like.
History
Date User Action Args
2010-03-25 13:00:20eric.smithsetrecipients: + eric.smith, rhettinger, ezio.melotti, r.david.murray, gruszczy, ebehar
2010-03-25 13:00:20eric.smithsetmessageid: <1269522020.6.0.3927200936.issue6081@psf.upfronthosting.co.za>
2010-03-25 13:00:19eric.smithlinkissue6081 messages
2010-03-25 13:00:18eric.smithcreate