Re: [Python-Dev] #2651 - KeyError does not round trip strings

2010-08-05 Thread Nick Coghlan
2010/8/5 Fred Drake : > 2010/8/4 Łukasz Langa : >> Shall we do an e.index for IndexErrors as well? > > I don't recall stumbling over that need, but the parallel makes it > tempting.  I expect is should be a separate patch, though. > > Antoine's right about using keyword args from C, though.  I'd ex

Re: [Python-Dev] #2651 - KeyError does not round trip strings

2010-08-04 Thread Fred Drake
2010/8/4 Łukasz Langa : > Shall we do an e.index for IndexErrors as well? I don't recall stumbling over that need, but the parallel makes it tempting. I expect is should be a separate patch, though. Antoine's right about using keyword args from C, though. I'd expect a new helper function that h

Re: [Python-Dev] #2651 - KeyError does not round trip strings

2010-08-04 Thread Antoine Pitrou
On Thu, 5 Aug 2010 07:57:07 +1000 Nick Coghlan wrote: > > +1 on what Fred said (i.e. post-moratorium, add a keyword-only "key" > argument to KeyError, set "e.key" only if that argument is supplied, > update the standard library to supply it and use a default message of > "'Key not found: %r' % ke

Re: [Python-Dev] #2651 - KeyError does not round trip strings

2010-08-04 Thread Eric Smith
On 8/4/2010 6:09 PM, Nick Coghlan wrote: On Thu, Aug 5, 2010 at 8:02 AM, Fred Drake wrote: On Wed, Aug 4, 2010 at 5:57 PM, Nick Coghlan wrote: and use a default message of "'Key not found: %r' % key" if the key argument is supplied without an explicit message I suspect you meant a default m

Re: [Python-Dev] #2651 - KeyError does not round trip strings

2010-08-04 Thread Łukasz Langa
Wiadomość napisana przez Nick Coghlan w dniu 2010-08-04, o godz. 23:57: > 2010/8/5 Fred Drake : >> 2010/8/4 Łukasz Langa : >>> 1. The patch makes KeyError behave analogically to IOError so that the first >>> arg is now a message and the second is the actual key. >> >> I agree with Antoine; there

Re: [Python-Dev] #2651 - KeyError does not round trip strings

2010-08-04 Thread Nick Coghlan
On Thu, Aug 5, 2010 at 8:02 AM, Fred Drake wrote: > On Wed, Aug 4, 2010 at 5:57 PM, Nick Coghlan wrote: >> and use a default message of >> "'Key not found: %r' % key" if the key argument is supplied without an >> explicit message > > I suspect you meant a default message of > >    'Key not found:

Re: [Python-Dev] #2651 - KeyError does not round trip strings

2010-08-04 Thread Fred Drake
On Wed, Aug 4, 2010 at 5:57 PM, Nick Coghlan wrote: > and use a default message of > "'Key not found: %r' % key" if the key argument is supplied without an > explicit message I suspect you meant a default message of 'Key not found: %r' % (key,) since `key` might be a 1-tuple. :-)   -Fred

Re: [Python-Dev] #2651 - KeyError does not round trip strings

2010-08-04 Thread Nick Coghlan
2010/8/5 Fred Drake : > 2010/8/4 Łukasz Langa : >> 1. The patch makes KeyError behave analogically to IOError so that the first >> arg is now a message and the second is the actual key. > > I agree with Antoine; there's no point to this. > >> 2. Some people suggest adding e.key to KeyError. I like

Re: [Python-Dev] #2651 - KeyError does not round trip strings

2010-08-04 Thread Fred Drake
2010/8/4 Łukasz Langa : > 1. The patch makes KeyError behave analogically to IOError so that the first > arg is now a message and the second is the actual key. I agree with Antoine; there's no point to this. > 2. Some people suggest adding e.key to KeyError. I like the idea but in my > opinion cu

Re: [Python-Dev] #2651 - KeyError does not round trip strings

2010-08-04 Thread Antoine Pitrou
On Wed, 4 Aug 2010 15:39:16 +0200 Łukasz Langa wrote: > 1. The patch makes KeyError behave analogically to IOError so that the first > arg is now a message and the second is the actual key. > > >>> raise KeyError("Key not found", "a Scotsman on a horse") > Traceback (most recent call last): > ..