On Friday, August 11, 2017 at 8:33:32 PM UTC+5:30, Ian wrote:
> The grand-daddy of them all, NPL (which actually called them "set
> comprehensions" after mathematics):
>
> setofeven(X) <= <:x: x in X & even(x) :>
Thanks for reminding of NPL; will add it to my history summary at
http://blog.langua
On Sat, 12 Aug 2017 12:45 am, Michael Torrie wrote:
> On 08/10/2017 11:29 PM, Steve D'Aprano wrote:
>> On Fri, 11 Aug 2017 12:54 pm, Mikhail V wrote:
>>
>>> but at a first glance, "while" reads as "if" as in english.
>>
>> In English the two words don't mean the same thing.
> But actually in som
Steve D'Aprano writes:
> Every few years, the following syntax comes up for discussion, with some
> people
> saying it isn't obvious what it would do, and others disagreeing and saying
> that it is obvious. So I thought I'd do an informal survey.
>
> What would you expect this syntax to return?
On Thu, Aug 10, 2017 at 11:45 PM, Steve D'Aprano
wrote:
> On Fri, 11 Aug 2017 08:49 am, Ben Finney wrote:
>
>> The comprehension encourages thinking in sets: an operation that takes a
>> collection as input, and emits a different collection, through one
>> conceptual operation.
>>
>> Adding ‘while
On 08/10/2017 11:29 PM, Steve D'Aprano wrote:
> On Fri, 11 Aug 2017 12:54 pm, Mikhail V wrote:
>
>> but at a first glance, "while" reads as "if" as in english.
>
> In English the two words don't mean the same thing.
But actually in some contexts they really do seem to mean the same thing:
Make h
On Fri, Aug 11, 2017 at 6:53 AM, Serhiy Storchaka wrote:
> 10.08.17 23:28, Ian Kelly пише:
>>
>> So, perhaps a better syntax could be:
>>
>> [x + 1 for x in (0, 1, 2, 999, 3, 4) if x < 5 else break]
>
>
> (0, 1, 2, 999, 3, 4) if x < 5 else break
>
> looks too similar to the ternary operator.
On 8/11/17 6:37 AM, Python wrote:
> Marko Rauhamaa wrote:
>> Python :
>>
>>> Marko Rauhamaa wrote:
>>> I didn't disagree with any of these statements about __hash__, but only
>>> your statement about id and __eq__:
>>>
id() is actually an ideal return value of __hash__(). The only
criter
Serhiy Storchaka :
> 10.08.17 17:28, Steve D'Aprano пише:
>> What would you expect this syntax to return?
>>
>> [x + 1 for x in (0, 1, 2, 999, 3, 4) while x < 5]
>
> I would expect it to be equivalent to the following code:
>
> result = []
> for x in (0, 1, 2, 999, 3, 4):
> while x
10.08.17 23:28, Ian Kelly пише:
So, perhaps a better syntax could be:
[x + 1 for x in (0, 1, 2, 999, 3, 4) if x < 5 else break]
(0, 1, 2, 999, 3, 4) if x < 5 else break
looks too similar to the ternary operator.
--
https://mail.python.org/mailman/listinfo/python-list
10.08.17 17:28, Steve D'Aprano пише:
Every few years, the following syntax comes up for discussion, with some people
saying it isn't obvious what it would do, and others disagreeing and saying
that it is obvious. So I thought I'd do an informal survey.
What would you expect this syntax to return
Ian Kelly writes:
> On Thu, Aug 10, 2017 at 8:28 AM, Steve D'Aprano
> wrote:
>> What would you expect this syntax to return?
>>
>> [x + 1 for x in (0, 1, 2, 999, 3, 4) while x < 5]
>
> I would expect the for to be an outer loop and the while to be an
> inner, so this would loop infinitely.
+1.
Marko Rauhamaa wrote:
Python :
Marko Rauhamaa wrote:
I didn't disagree with any of these statements about __hash__, but only
your statement about id and __eq__:
id() is actually an ideal return value of __hash__(). The only
criterion is that the returned number should be different if the
__e
Steve D'Aprano writes:
> What would you expect this syntax to return?
> [x + 1 for x in (0, 1, 2, 999, 3, 4) while x < 5]
[1,2,3] though the later example is more confusing.
I don't think we need this since we have itertools.takewhile:
from operator import gt
from functools import partial
13 matches
Mail list logo