On Aug 25, 11:57 pm, Piet van Oostrum wrote:
> You can also say:
> [x+y for x in range(3) for y in range(4) if x < y]
> If you want to write this as a loop you have to put the for's on
> separate lines separated by colons, so why not the if also? Or would you
> also like to have the for's on one l
> seb (s) wrote:
>s> i am still a bit puzzle by the following.
>s> I read in
>http://en.wikipedia.org/wiki/Python_syntax_and_semantics#Generators
>s> """Python 3.0 unifies all collection types by introducing dict and set
>s> comprehensions, similar to list comprehensions:
> [ n*n for
On Aug 25, 10:46 pm, Falcolas wrote:
> On Aug 25, 1:58 pm, seb wrote:
>
> > On Aug 25, 9:42 pm, Falcolas wrote:
> > > On Aug 25, 11:25 am, seb wrote:
> > > So, what part of the statement does the "if" statement belong to;
> > > particularly a concern considering this is valid python:
>
> > > fo
On Aug 25, 1:58 pm, seb wrote:
> On Aug 25, 9:42 pm, Falcolas wrote:
> > On Aug 25, 11:25 am, seb wrote:
> > So, what part of the statement does the "if" statement belong to;
> > particularly a concern considering this is valid python:
>
> > for x in y if y else z:
> > body
>
> can this be d
On Aug 25, 9:42 pm, Falcolas wrote:
> On Aug 25, 11:25 am, seb wrote:
>
>
>
> > We could as consistenly explain that the syntax
>
> > for n in range(10) if n%3==0:
> > body
>
> > means
>
> > for n in range(10):
> > if n%3==0:
> > body
>
> > This syntax has also the benefit of avoiding an
On Aug 25, 11:25 am, seb wrote:
> We could as consistenly explain that the syntax
>
> for n in range(10) if n%3==0:
> body
>
> means
>
> for n in range(10):
> if n%3==0:
> body
>
> This syntax has also the benefit of avoiding an extra level of
> indentation (the one for the if) that bears
We could as consistenly explain that the syntax
for n in range(10) if n%3==0:
body
means
for n in range(10):
if n%3==0:
body
This syntax has also the benefit of avoiding an extra level of
indentation (the one for the if) that bears no real meaning on a
structural level.
I'm sorry, I
On Aug 24, 12:05 am, Mel wrote:
> seb wrote:
> > On Aug 23, 6:18 pm, John Posner wrote:
> [ ... ]
> >> How about using a generator expression instead of a list?
>
> >> for i in (x for x in range(10) if x > 5):
> >> print i
>
> >> -John
>
> > Indeed, but we could have the same syntax than for gene
On Aug 23, 11:02 pm, Chris Rebert wrote:
> On Sun, Aug 23, 2009 at 1:36 PM, seb wrote:
> > On Aug 23, 6:18 pm, John Posner wrote:
> >> >> Hi,
>
> >> >> i was wondering if there is a syntax alike:
>
> >> >> for i in range(10) if i > 5:
> >> >> print i
>
> >> > You can write
>
> >> > for i in f
seb a écrit :
Hi,
i was wondering if there is a syntax alike:
for i in range(10) if i > 5:
print i
equivalent to
for i in (for i in range(10) if i>5):
print i
what about :
for i in range(6, 10):
print i
More seriously:
for i in range(10):
if i > 5:
print i
--
h
seb wrote:
> On Aug 23, 6:18 pm, John Posner wrote:
[ ... ]
>> How about using a generator expression instead of a list?
>>
>> for i in (x for x in range(10) if x > 5):
>> print i
>>
>> -John
>
> Indeed, but we could have the same syntax than for generators but
> directly in the for statement as
On Sun, Aug 23, 2009 at 1:36 PM, seb wrote:
> On Aug 23, 6:18 pm, John Posner wrote:
>> >> Hi,
>>
>> >> i was wondering if there is a syntax alike:
>>
>> >> for i in range(10) if i > 5:
>> >> print i
>>
>> > You can write
>>
>> > for i in filter(lambda i: i > 5, range(10)):
>> > print i
>>
On Aug 23, 10:36 pm, seb wrote:
> On Aug 23, 6:18 pm, John Posner wrote:
>
>
>
>
>
> > >> Hi,
>
> > >> i was wondering if there is a syntax alike:
>
> > >> for i in range(10) if i > 5:
> > >> print i
>
> > > You can write
>
> > > for i in filter(lambda i: i > 5, range(10)):
> > > print i
On Aug 23, 6:18 pm, John Posner wrote:
> >> Hi,
>
> >> i was wondering if there is a syntax alike:
>
> >> for i in range(10) if i > 5:
> >> print i
>
> > You can write
>
> > for i in filter(lambda i: i > 5, range(10)):
> > print i
>
> > but
>
> > for i in range(10):
> > if i > 5:
> >
Hi,
i was wondering if there is a syntax alike:
for i in range(10) if i > 5:
print i
You can write
for i in filter(lambda i: i > 5, range(10)):
print i
but
for i in range(10):
if i > 5:
print i
it' better readable, and
for i in range(6,10):
print i
it's e
Il Sun, 23 Aug 2009 01:09:04 -0700 (PDT), seb ha scritto:
> Hi,
>
> i was wondering if there is a syntax alike:
>
> for i in range(10) if i > 5:
> print i
You can write
for i in filter(lambda i: i > 5, range(10)):
print i
but
for i in range(10):
if i > 5:
print i
it' be
On Aug 23, 10:09 am, seb wrote:
> Hi,
>
> i was wondering if there is a syntax alike:
>
> for i in range(10) if i > 5:
> print i
>
> equivalent to
>
> for i in (for i in range(10) if i>5):
> print i
>
> sebastien
AFAIK, no syntax fo that. But the standard syntax is not too
different:
for
seb gmail.com> writes:
>
> Hi,
>
> i was wondering if there is a syntax alike:
>
> for i in range(10) if i > 5:
> print i
for i in range(10):
if i > 5:
print i
--
http://mail.python.org/mailman/listinfo/python-list
Hi,
i was wondering if there is a syntax alike:
for i in range(10) if i > 5:
print i
equivalent to
for i in (for i in range(10) if i>5):
print i
sebastien
--
http://mail.python.org/mailman/listinfo/python-list
19 matches
Mail list logo