Re: [Python-Dev] inplace operators and __setitem__

2005-09-29 Thread Pierre Barbier de Reuille
Done :) I summarized my point of view and I'm waiting for comments :) Pierre Aahz a écrit : > On Thu, Sep 29, 2005, Pierre Barbier de Reuille wrote: > >>Ok, so I took a closer look at the documentation and tried a few things >>to understand better what you said and I have some remark ... > >

Re: [Python-Dev] inplace operators and __setitem__

2005-09-29 Thread Aahz
On Thu, Sep 29, 2005, Pierre Barbier de Reuille wrote: > > Ok, so I took a closer look at the documentation and tried a few things > to understand better what you said and I have some remark ... I've got some counter-remarks, but python-dev is not the place to discuss them. Please move this threa

Re: [Python-Dev] inplace operators and __setitem__

2005-09-28 Thread Pierre Barbier de Reuille
Ok, so I took a closer look at the documentation and tried a few things to understand better what you said and I have some remark ... Phillip J. Eby a ecrit : > At 06:15 PM 9/28/2005 +0200, Pierre Barbier de Reuille wrote: > >> Regularly, you see questions about augmented assignment on Python-tut

Re: [Python-Dev] inplace operators and __setitem__

2005-09-28 Thread Phillip J. Eby
At 06:15 PM 9/28/2005 +0200, Pierre Barbier de Reuille wrote: >Regularly, you see questions about augmented assignment on Python-tutor >mailing list, I often have question in my lab because of problems ... >most of the time people learn to avoid these operators in the end ! And >my look in the stan

Re: [Python-Dev] inplace operators and __setitem__

2005-09-28 Thread Pierre Barbier de Reuille
Phillip J. Eby a écrit : > At 05:40 PM 9/28/2005 +0200, Pierre Barbier de Reuille wrote: > >> Rather than closing this as invalid, it would be wiser to update the >> documentation before ! Nothing corresponds to the current behavior. > > > I got my information from here: > > http://www.python.

Re: [Python-Dev] inplace operators and __setitem__

2005-09-28 Thread Phillip J. Eby
At 05:40 PM 9/28/2005 +0200, Pierre Barbier de Reuille wrote: >Rather than closing this as invalid, it would be wiser to update the >documentation before ! Nothing corresponds to the current behavior. I got my information from here: http://www.python.org/2.0/new-python.html#SECTION0007000

Re: [Python-Dev] inplace operators and __setitem__

2005-09-28 Thread Phillip J. Eby
At 05:15 PM 9/28/2005 +0200, Reinhold Birkenfeld wrote: >Okay. I assume that we must accept that > >s = set() >t = (s,) >t[0] |= set([1]) > >changes s in spite of raising TypeError. There are lots of operations that can be partially completed before raising an error, so I'm not sure why this case

Re: [Python-Dev] inplace operators and __setitem__

2005-09-28 Thread Pierre Barbier de Reuille
Phillip J. Eby a écrit : > At 03:12 PM 9/28/2005 +0200, Reinhold Birkenfeld wrote: [...] > Yes. See: > > http://www.python.org/2.0/new-python.html#SECTION00070 > > The purpose of the augmented assignment forms is to allow for the > possibility that the item's __i*__ method may o

Re: [Python-Dev] inplace operators and __setitem__

2005-09-28 Thread Reinhold Birkenfeld
Phillip J. Eby wrote: >>A case where this matters is here: http://python.org/sf/1306777 > > I've closed it as invalid; the behavior is as-defined. > > In principle, there *could* be an optimization to avoid rebinding the > lvalue in the case where the __i*__ form did return self. But using it

Re: [Python-Dev] inplace operators and __setitem__

2005-09-28 Thread Phillip J. Eby
At 03:12 PM 9/28/2005 +0200, Reinhold Birkenfeld wrote: >Hi, > >a general question. Consider: > >class A(list): > def __setitem__(self, index, item): > # do something with index and item > return list.__setitem__(self, index, item) > >lst = A([1,set()]) > >lst[0] |= 1 > >lst[1]

Re: [Python-Dev] inplace operators and __setitem__

2005-09-28 Thread James Y Knight
On Sep 28, 2005, at 9:12 AM, Reinhold Birkenfeld wrote: > Hi, > > a general question. Consider: > > class A(list): > def __setitem__(self, index, item): > # do something with index and item > return list.__setitem__(self, index, item) > > lst = A([1,set()]) > > lst[0] |= 1 > >

[Python-Dev] inplace operators and __setitem__

2005-09-28 Thread Reinhold Birkenfeld
Hi, a general question. Consider: class A(list): def __setitem__(self, index, item): # do something with index and item return list.__setitem__(self, index, item) lst = A([1,set()]) lst[0] |= 1 lst[1] |= set([1]) Do we want lst.__setitem__ to be called in the second inplac