On Wed, Feb 23, 2011 at 9:32 AM, Senthil Kumaran <orsent...@gmail.com> wrote: > """ > Because keys are not quote-delimited, it is not possible to > specify arbitrary dictionary keys (e.g., the strings "10" or > ":-]") from within a format string. > """
I was curious as to whether or not nested substitution could be used to avoid that limitation, but it would seem not: >>> "{0[{1}]}".format(d, 21.2) Traceback (most recent call last): File "<stdin>", line 1, in <module> KeyError: '{1}' Turns out that was also a deliberate design choice: """ These 'internal' replacement fields can only occur in the format specifier part of the replacement field. Internal replacement fields cannot themselves have format specifiers. This implies also that replacement fields cannot be nested to arbitrary levels. """ Ah, how (much more) confused would we be if we didn't have the PEPs and mailing list archives to remind ourselves of what we were thinking years ago... Cheers, Nick. -- Nick Coghlan | ncogh...@gmail.com | Brisbane, Australia _______________________________________________ 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