Re: Python 3000 idea -- + on iterables -> itertools.chain

2006-11-13 Thread Carl Banks
George Sakkis wrote: > Carl Banks wrote: > > George Sakkis wrote: > > > If by 'respond to "+"' is implied that you can get a "TypeError: > > > iterable argument required", as you get now for attempting "x in y" for > > > non-iterable y, why not ? > > > > Bad idea on many, many levels. Don't go th

Re: Python 3000 idea -- + on iterables -> itertools.chain

2006-11-13 Thread Georg Brandl
Carl Banks wrote: > Georg Brandl wrote: >> What has a better chance of success in my eyes is an extension to yield >> all items from an iterable without using an explicit for loop: instead of >> >> for item in iterable: >> yield item >> >> you could write >> >> yield from iterable >> >> or >>

Re: Python 3000 idea -- + on iterables -> itertools.chain

2006-11-13 Thread George Sakkis
Carl Banks wrote: > George Sakkis wrote: > > Fredrik Lundh wrote: > > > > > George Sakkis wrote: > > > > > > > The base object class would be one candidate, similarly to the way > > > > __nonzero__ is defined to use __len__, or __contains__ to use __iter__. > > > > > > > > Alternatively, iter() co

Re: Python 3000 idea -- + on iterables -> itertools.chain

2006-11-13 Thread Carl Banks
George Sakkis wrote: > Fredrik Lundh wrote: > > > George Sakkis wrote: > > > > > The base object class would be one candidate, similarly to the way > > > __nonzero__ is defined to use __len__, or __contains__ to use __iter__. > > > > > > Alternatively, iter() could be a wrapper type (or perhaps mix

Re: Python 3000 idea -- + on iterables -> itertools.chain

2006-11-13 Thread Carl Banks
Georg Brandl wrote: > What has a better chance of success in my eyes is an extension to yield > all items from an iterable without using an explicit for loop: instead of > > for item in iterable: > yield item > > you could write > > yield from iterable > > or > > yield *iterable Since this is

Re: Python 3000 idea -- + on iterables -> itertools.chain

2006-11-13 Thread George Sakkis
Fredrik Lundh wrote: > George Sakkis wrote: > > > The base object class would be one candidate, similarly to the way > > __nonzero__ is defined to use __len__, or __contains__ to use __iter__. > > > > Alternatively, iter() could be a wrapper type (or perhaps mixin) > > instead of a function, somet

Re: Python 3000 idea -- + on iterables -> itertools.chain

2006-11-13 Thread Georg Brandl
George Sakkis wrote: > Fredrik Lundh wrote: > >> John Reese wrote: >> >> > It seems like it would be clear and mostly backwards compatible if the >> > + operator on any iterables created a new iterable that iterated >> > throught first its left operand and then its right, in the style of >> > iter

Re: Python 3000 idea -- + on iterables -> itertools.chain

2006-11-12 Thread Fredrik Lundh
George Sakkis wrote: > The base object class would be one candidate, similarly to the way > __nonzero__ is defined to use __len__, or __contains__ to use __iter__. > > Alternatively, iter() could be a wrapper type (or perhaps mixin) > instead of a function, something like: so you're proposing to

Re: Python 3000 idea -- + on iterables -> itertools.chain

2006-11-12 Thread George Sakkis
Fredrik Lundh wrote: > John Reese wrote: > > > It seems like it would be clear and mostly backwards compatible if the > > + operator on any iterables created a new iterable that iterated > > throught first its left operand and then its right, in the style of > > itertools.chain. > > you do know th

Re: Python 3000 idea -- + on iterables -> itertools.chain

2006-11-12 Thread Fredrik Lundh
John Reese wrote: > It seems like it would be clear and mostly backwards compatible if the > + operator on any iterables created a new iterable that iterated > throught first its left operand and then its right, in the style of > itertools.chain. you do know that "iterable" is an informal interf

Python 3000 idea -- + on iterables -> itertools.chain

2006-11-12 Thread John Reese
It seems like it would be clear and mostly backwards compatible if the + operator on any iterables created a new iterable that iterated throught first its left operand and then its right, in the style of itertools.chain. This would allow summation of generator expressions, among other things, to h