Re: syntax enhancement

2011-10-05 Thread Steven D'Aprano
On Wed, 05 Oct 2011 13:31:41 -0500, Tim Chase wrote: > I'm very -1 on the initial proposal with parens, but I wouldn't object > to generators growing a method (__getitem__?) to do slices via > itertools, something like > >gen = (a for a in iterator if test(a)) >for thing in gen[4::2]: >

Re: syntax enhancement

2011-10-05 Thread Ian Kelly
On Wed, Oct 5, 2011 at 3:28 PM, Westley Martínez wrote: > Wait, how would this work fundamentally?  A list can be sliced because > all the values are there.  A generator does not have all its value at > once (it generates each value as requested).  I don't like change so I > look at these kinds of

Re: syntax enhancement

2011-10-05 Thread Westley Martínez
On Wed, Oct 05, 2011 at 01:31:41PM -0500, Tim Chase wrote: > On 10/04/11 20:45, Terry Reedy wrote: > >On 10/4/2011 9:50 AM, Valiev Sergey wrote: > > > >>- `[]` - used for list comprehension, > >>- `()` - used for generators, > >>- `[start:stop]` / `[start:stop:step]` - used for slices. > >>The idea

Re: syntax enhancement

2011-10-05 Thread Terry Reedy
On 10/5/2011 2:31 PM, Tim Chase wrote: On 10/04/11 20:45, Terry Reedy wrote: On 10/4/2011 9:50 AM, Valiev Sergey wrote: - `[]` - used for list comprehension, - `()` - used for generators, - `[start:stop]` / `[start:stop:step]` - used for slices. The idea is to use `(start:stop)` / `(start:stop

Re: syntax enhancement

2011-10-05 Thread Tim Chase
On 10/04/11 20:45, Terry Reedy wrote: On 10/4/2011 9:50 AM, Valiev Sergey wrote: - `[]` - used for list comprehension, - `()` - used for generators, - `[start:stop]` / `[start:stop:step]` - used for slices. The idea is to use `(start:stop)` / `(start:stop:step)` as 'lazy evaluated' slices (like

Re: syntax enhancement

2011-10-04 Thread Terry Reedy
On 10/4/2011 9:50 AM, Valiev Sergey wrote: - `[]` - used for list comprehension, - `()` - used for generators, - `[start:stop]` / `[start:stop:step]` - used for slices. The idea is to use `(start:stop)` / `(start:stop:step)` as 'lazy evaluated' slices (like itertools.islice). What do you think a

Re: syntax enhancement

2011-10-04 Thread Calvin Spealman
On Tue, Oct 4, 2011 at 9:50 AM, Valiev Sergey wrote: > Hi, > you may found this idea stupid, but nevertheless... > - `[]` - used for list comprehension, > - `()` - used for generators, > - `[start:stop]` / `[start:stop:step]` - used for slices. > The idea is to use `(start:stop)` / `(start:stop:s

syntax enhancement

2011-10-04 Thread Valiev Sergey
Hi, you may found this idea stupid, but nevertheless... - `[]` - used for list comprehension, - `()` - used for generators, - `[start:stop]` / `[start:stop:step]` - used for slices. The idea is to use `(start:stop)` / `(start:stop:step)` as 'lazy evaluated' slices (like itertools.islice). What do y