Re: [Python-ideas] Suggested MapView object (Re: __len__() for map())

2018-12-02 Thread Greg Ewing
Steven D'Aprano wrote: Perhaps more like the principle of most astonishment: the object changes from sized to unsized even if you don't modify its value or its type, but merely if you look at it the wrong way: Yes, but keep in mind the purpose of the whole thing is to provide a sequence inter

Re: [Python-ideas] Suggested MapView object (Re: __len__() for map())

2018-12-02 Thread Steven D'Aprano
On Mon, Dec 03, 2018 at 02:04:31AM +1300, Greg Ewing wrote: > Chris Angelico wrote: > >I can't help thinking that it will be extremely surprising to have the > >length remain the same while the items get consumed. > > That can be fixed. The following version raises an exception if > you try to fin

Re: [Python-ideas] Suggested MapView object (Re: __len__() for map())

2018-12-02 Thread Greg Ewing
Chris Angelico wrote: I can't help thinking that it will be extremely surprising to have the length remain the same while the items get consumed. That can be fixed. The following version raises an exception if you try to find the length after having used it as an iterator. (I also fixed a bug -