Re: [Python-Dev] Fwd: deep question re dict as formatting input

2011-02-23 Thread Eric Smith
> On Feb 23, 2011, at 5:42 AM, Nick Coghlan wrote: > >> 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... >> > True. And how much more useful it would be if it were incorporated into > the do

Re: [Python-Dev] Fwd: deep question re dict as formatting input

2011-02-23 Thread Ethan Furman
Eric Smith wrote: On 2/22/2011 6:28 PM, Steve Holden wrote: On Feb 22, 2011, at 3:08 PM, Eric Smith wrote: Quoting PEP 3101: An example of the 'getitem' syntax: "My name is {0[name]}".format(dict(name='Fred')) It should be noted that the use of 'getitem' within a format string is muc

Re: [Python-Dev] Fwd: deep question re dict as formatting input

2011-02-23 Thread Steve Holden
On Feb 23, 2011, at 5:42 AM, Nick Coghlan wrote: > 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... > True. And how much more useful it would be if it were incorporated into the documentati

Re: [Python-Dev] Fwd: deep question re dict as formatting input

2011-02-23 Thread Eric Smith
On 02/23/2011 09:42 AM, R. David Murray wrote: On Tue, 22 Feb 2011 19:32:56 -0500, Eric Smith wrote: You are correct, I didn't exactly implement the PEP on this point, probably as a shortcut. I think there's an issue somewhere that discusses this, but I can't find it. The CPython implementation

Re: [Python-Dev] Fwd: deep question re dict as formatting input

2011-02-23 Thread R. David Murray
On Tue, 22 Feb 2011 19:32:56 -0500, Eric Smith wrote: > You are correct, I didn't exactly implement the PEP on this point, > probably as a shortcut. I think there's an issue somewhere that > discusses this, but I can't find it. The CPython implementation is > really using "If every character is

Re: [Python-Dev] Fwd: deep question re dict as formatting input

2011-02-23 Thread Nick Coghlan
On Wed, Feb 23, 2011 at 9:32 AM, Senthil Kumaran 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

Re: [Python-Dev] Fwd: deep question re dict as formatting input

2011-02-23 Thread Eric Smith
On 02/22/2011 07:32 PM, Eric Smith wrote: On 2/22/2011 6:28 PM, Steve Holden wrote: On Feb 22, 2011, at 3:08 PM, Eric Smith wrote: Quoting PEP 3101: An example of the 'getitem' syntax: "My name is {0[name]}".format(dict(name='Fred')) It should be noted that the use of 'getitem' within a fo

Re: [Python-Dev] Fwd: deep question re dict as formatting input

2011-02-22 Thread Eric Smith
On 2/22/2011 6:28 PM, Steve Holden wrote: On Feb 22, 2011, at 3:08 PM, Eric Smith wrote: Quoting PEP 3101: An example of the 'getitem' syntax: "My name is {0[name]}".format(dict(name='Fred')) It should be noted that the use of 'getitem' within a format string is much more limited th

Re: [Python-Dev] Fwd: deep question re dict as formatting input

2011-02-22 Thread Terry Reedy
On 2/22/2011 6:32 PM, Senthil Kumaran wrote: On Tue, Feb 22, 2011 at 6:01 PM, Steve Holden 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

Re: [Python-Dev] Fwd: deep question re dict as formatting input

2011-02-22 Thread Senthil Kumaran
> On Tue, Feb 22, 2011 at 6:01 PM, Steve Holden 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 itsel

Re: [Python-Dev] Fwd: deep question re dict as formatting input

2011-02-22 Thread Steve Holden
On Feb 22, 2011, at 3:08 PM, Eric Smith wrote: > Quoting PEP 3101: > > An example of the 'getitem' syntax: > >"My name is {0[name]}".format(dict(name='Fred')) > > It should be noted that the use of 'getitem' within a format string > is much more limited than its conventional usage. In

Re: [Python-Dev] Fwd: deep question re dict as formatting input

2011-02-22 Thread Eric Smith
Quoting PEP 3101: An example of the 'getitem' syntax: "My name is {0[name]}".format(dict(name='Fred')) It should be noted that the use of 'getitem' within a format string is much more limited than its conventional usage. In the above example, the string 'name' really is the literal str

Re: [Python-Dev] Fwd: deep question re dict as formatting input

2011-02-22 Thread Alexander Belopolsky
On Tue, Feb 22, 2011 at 6:01 PM, Steve Holden 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 a