Re: any() and all() shorthand

2008-01-07 Thread castironpi
>print 'lookahead2(initial=3.14159, last=42)' >for this, next in lookahead2([1,2,3,4,5], >initial=3.14159, last=42): > print this, next No, actually. But my mistake. [ a.b() or _previous_ for a in c ] means 1 or 2 or 3 or 4 or 5 where c= [ 1, 2, 3, 4, 5]. The mistake: thi

Re: any() and all() shorthand

2008-01-07 Thread Tim Chase
> The idea is a shorthand for reduce. Here, _next_ meant the next item > in the iterable c. You mean like one of these: def lookahead(iterator): i = iter(iterator) x = i.next() for item in i: yield x, item x = item def lookahead2(iterator, **kwarg): i = i

Re: any() and all() shorthand

2008-01-07 Thread castironpi
On Jan 7, 1:45 pm, [EMAIL PROTECTED] wrote: > On Jan 7, 1:29 pm, "Guilherme Polo" <[EMAIL PROTECTED]> wrote: > > The idea is a shorthand for reduce. Here, _next_ meant the next item > in the iterable c. 'Only' is another known quantifier in logic: 'all and only'. Any (there exists) and all (for

Re: any() and all() shorthand

2008-01-07 Thread castironpi
On Jan 7, 1:29 pm, "Guilherme Polo" <[EMAIL PROTECTED]> wrote: > 2008/1/7, [EMAIL PROTECTED] <[EMAIL PROTECTED]>: > > > > You are too late, any and all are built-in into python 2.5 > > > Hi, excellent. Now how about something more generic, possibly: > > > [ x.y() for x or _next_ in c ] > > > where

Re: any() and all() shorthand

2008-01-07 Thread Guilherme Polo
2008/1/7, [EMAIL PROTECTED] <[EMAIL PROTECTED]>: > > You are too late, any and all are built-in into python 2.5 > > Hi, excellent. Now how about something more generic, possibly: > > [ x.y() for x or _next_ in c ] > > where the context of _next_ is limited in complexity, and/or can only > occur in

Re: any() and all() shorthand

2008-01-07 Thread castironpi
> You are too late, any and all are built-in into python 2.5 Hi, excellent. Now how about something more generic, possibly: [ x.y() for x or _next_ in c ] where the context of _next_ is limited in complexity, and/or can only occur in a generator? -- http://mail.python.org/mailman/listinfo/pyth

Re: any() and all() shorthand

2008-01-07 Thread Guilherme Polo
2008/1/7, [EMAIL PROTECTED] <[EMAIL PROTECTED]>: > any( iterab ) and all( iterab ) > > as shorthand for reduce( operator.or_, iterab ) and > reduce( operator.and_, iterab ). > > What do you think? > -- > http://mail.python.org/mailman/listinfo/python-list > You are too late, any and all are built-

any() and all() shorthand

2008-01-07 Thread castironpi
any( iterab ) and all( iterab ) as shorthand for reduce( operator.or_, iterab ) and reduce( operator.and_, iterab ). What do you think? -- http://mail.python.org/mailman/listinfo/python-list