On 10/31/2010 6:28 PM, Glenn Linderman wrote:
On 10/31/2010 2:02 PM, Benjamin Peterson wrote:
2010/10/31 Antoine Pitrou<solip...@pitrou.net>:
> On Sun, 31 Oct 2010 16:39:44 -0400
> Eric Smith<e...@trueblade.com> wrote:
>
>> What are your thoughts on adding a str.format_from_mapping (or similar
>> name, maybe the suggested "format_map") to 3.2? See
>> http://bugs.python.org/issue6081 . This method would be similar to
>> "%(foo)s %(bar)s" % d, where d is a dict (or rather any mapping object),
>> but of course would use str.format syntax: "{foo}
>> {bar}".format_from_mapping(d).
>
> I must be missing something, but what's the difference with
> XXX.format(**d)?
It allows arbitrary mappings.
Other than the language moratorium, why are arbitrary mappings not
allowed for the (**d) syntax?
An arbitrary mapping would be converted to a dict. That disallows using
a subclass with __missing__ defined, among other things. See the
discussion in the issue.
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com