On Sun, Nov 23, 2014 at 8:42 PM, Steven D'Aprano wrote:
> On Sun, 23 Nov 2014 08:45:39 -0800, Rustom Mody wrote:
>> First a one-line solution in haskell
>>
>> sieve (p:xs) =p:sieve [x | x <- xs, x `mod` p /= 0]
>
> Don't use that! That is a horribly inefficient way to generate primes.
>
> Ma
Chris Angelico wrote:
> On Mon, Nov 24, 2014 at 3:42 PM, Steven D'Aprano
> wrote:
>> Today dis() returns the above, tomorrow it may return:
>>
>> 0 LOAD_GLOBAL 0 (x)
>> 3 INCREMENT
>> 5 RETURN_VALUE
>>
>> (say), and the Python code remains th
On Monday, November 24, 2014 10:13:04 AM UTC+5:30, Steven D'Aprano wrote:
> On Sun, 23 Nov 2014 08:45:39 -0800, Rustom Mody wrote:
> > First a one-line solution in haskell
> >
> > sieve (p:xs) =p:sieve [x | x <- xs, x `mod` p /= 0]
>
> Don't use that! That is a horribly inefficient way to g
On Mon, Nov 24, 2014 at 3:42 PM, Steven D'Aprano wrote:
> Today dis() returns the above, tomorrow it may return:
>
> 0 LOAD_GLOBAL 0 (x)
> 3 INCREMENT
> 5 RETURN_VALUE
>
> (say), and the Python code remains the same even though the byte code i
On Sun, 23 Nov 2014 08:45:39 -0800, Rustom Mody wrote:
> 2. "List comprehensions are syntactic sugar for for loops" Cannot
> technically quarrel with that as that is the position of the official
> docs.
> However to me it puts the cart before the horse. Its like saying that
>
> def foo(x): return
On 2014-11-23, Roy Smith wrote:
> In article ,
> Skip Montanaro wrote:
>> > But it breaks all the picture that I've built in my head about comps till
>> > now...
>>
>> Note that list comprehensions are little more than syntactic sugar for for
>> loops. If you're having terrible writing or under
Rustom Mody
Sent: Sunday, November 23, 2014 18:46
To: python-list@python.org
Subject: Re: Comprehension with two variables - explanation needed
On Sunday, November 23, 2014 9:27:22 PM UTC+5:30, Roy Smith wrote:
> Skip Montanaro wrote:
>
> > > But it breaks all the picture that
On Sunday, November 23, 2014 10:15:51 PM UTC+5:30, Rustom Mody wrote:
> 1. I find comprehensions are harder than for-loops --
Heh! Meant to say 'easier' of course...
--
https://mail.python.org/mailman/listinfo/python-list
We seem to be somewhat more liberal about nested comprehensions here, but I
can't say I'm proud of that :-)
906 Python source files, 109k lines.
$ find . -name '*.py' | xargs grep '\[.* for .*\]' | wc -l
729
$ find . -name '*.py' | xargs grep '\[.* for .* for .*\]' | wc -l
46
Without naming n
On Sunday, November 23, 2014 9:27:22 PM UTC+5:30, Roy Smith wrote:
> Skip Montanaro wrote:
>
> > > But it breaks all the picture that I've built in my head about comps till
> > > now...
> >
> > Note that list comprehensions are little more than syntactic sugar for for
> > loops. If you're having
On Sun, Nov 23, 2014 at 9:57 AM, Roy Smith wrote:
>
> If it was complicated enough that you needed to loopify it to
> understand what it's doing, have pity on the next person who has to
> maintain your code and leave it as a loop
Well, sure. I was mostly trying to give Ivan a path out of the weed
In article ,
Skip Montanaro wrote:
> > But it breaks all the picture that I've built in my head about comps till
> > now...
>
> Note that list comprehensions are little more than syntactic sugar for for
> loops. If you're having terrible writing or understanding one, especially a
> compound one
> But it breaks all the picture that I've built in my head about comps till
> now...
Note that list comprehensions are little more than syntactic sugar for for
loops. If you're having terrible writing or understanding one, especially a
compound one like your example, it can help to write it as a (
On Mon, Nov 24, 2014 at 2:37 AM, Ivan Evstegneev
wrote:
> As I know from books and googling, the comps main idea looks approximately
> like this:
>
> [target <--main loop<--nested loop/s (and maybe some conditions)]Am I
> right?
>
> But your code looks somehow inverted to me o_0
>
> Like:
>
>
Ivan
-Original Message-
From: Python-list
[mailto:python-list-bounces+webmailgroups=gmail@python.org] On Behalf Of
Rustom Mody
Sent: Sunday, November 23, 2014 17:09
To: python-list@python.org
Subject: Re: Comprehension with two variables - explanation needed
On Sunday, Novem
On Mon, Nov 24, 2014 at 1:56 AM, Ivan Evstegneev
wrote:
>
> Hello guys,
>
> I would like to ask you for some explanations on comprehensions. (Don’t be
> scared, it just some particular example ^_^)
>
> I found this little “find prime number” example over the internet:
>
> >>> noprimes = [j for i
On Sunday, November 23, 2014 8:28:16 PM UTC+5:30, Ivan Evstegneev wrote:
> Hello guys,
>
> I would like to ask you for some explanations on comprehensions. (Don't be
> scared, it just some particular example ^_^)
>
> I found this little "find prime number" example over the internet:
>
> >>>
Hello guys,
I would like to ask you for some explanations on comprehensions. (Don't be
scared, it just some particular example ^_^)
I found this little "find prime number" example over the internet:
>>> noprimes = [j for i in range(2, 8) for j in range(i*2, 50, i)]
>>> primes = [x for x
18 matches
Mail list logo