> On Tue, Feb 22, 2011 at 6:01 PM, Steve Holden <st...@holdenweb.com> wrote:
>> ... It would appear from tests
>> that "{0[X]}".format(...) first tries to convert the string "X" to in
>> integer. If it succeeds then __getitem__() is called with the integer as an
>> argument, otherwise it is called with the string itself as an argument. Is
>> this correct?
>
> This is addressed in the PEP 3101:
> """
>    The rules for parsing an item key are very simple.
>    If it starts with a digit, then it is treated as a number, otherwise
>    it is used as a string.
> """ http://www.python.org/dev/peps/pep-3101/

To the other question :

> Furthermore, how does one access the key '1' in a format statement?
> ~Ethan~

I think, parsing rule already helps to understand the problem with the
key like '1'.
The PEP also explicitly states that:

"""
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.
"""
-- 
Senthil
_______________________________________________
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

Reply via email to