Re: [Python-ideas] Temporary variables in comprehensions

2018-02-23 Thread Kyle Lahnakoski
On 2018-02-17 11:23, fhsxfhsx wrote: > [ >   { >     'id': goods.id, >     'name': goods.name, >     'category': gc.name, >     'category_type': gc.type, >   } >   for goods_id in goods_id_list >   for goods is Goods.get_by_id(goods_id) >   for gc is GoodsCategory.get_by_id(goods.category_id) > ]

Re: [Python-ideas] Temporary variables in comprehensions

2018-02-23 Thread Kyle Lahnakoski
I believe list comprehensions are difficult to read because they are not formatted properly. For me, list comprehension clauses are an expression, followed by clauses executed in the order. Any list comprehension with more than one clause should be one-line-per clause. Examples inline: On 2018-02

Re: [Python-ideas] Temporary variables in comprehensions

2018-02-23 Thread Neil Girdhar
On Fri, Feb 23, 2018 at 12:35 PM Kyle Lahnakoski wrote: > I believe list comprehensions are difficult to read because they are not > formatted properly. For me, list comprehension clauses are an > expression, followed by clauses executed in the order. Any list > comprehension with more than one c

Re: [Python-ideas] List assignment - extended slicing inconsistency

2018-02-23 Thread Chris Barker
On Thu, Feb 22, 2018 at 6:21 PM, Nick Coghlan wrote: > > (I wonder if the discrepancy is due to some internal interface that loses > > the distinction between None and 1 before the decision is made whether to > > use advanced slicing or not. But that's a possible explanation, not an > > excuse.)

Re: [Python-ideas] Temporary variables in comprehensions

2018-02-23 Thread Kyle Lahnakoski
On 2018-02-23 12:44, Neil Girdhar wrote: > > On Fri, Feb 23, 2018 at 12:35 PM Kyle Lahnakoski > mailto:[email protected]>> wrote: > > > > [ > > (w, w**2) > > for x in (1, 2, 3, 4) > > let y = x+1 > > for a in range(y) > > let z = a+1 > > i

Re: [Python-ideas] Temporary variables in comprehensions

2018-02-23 Thread Neil Girdhar
On Fri, Feb 23, 2018 at 1:42 PM Kyle Lahnakoski wrote: > > > On 2018-02-23 12:44, Neil Girdhar wrote: > > On Fri, Feb 23, 2018 at 12:35 PM Kyle Lahnakoski > wrote: > >> >> > [ >> > (w, w**2) >> > for x in (1, 2, 3, 4) >> > let y = x+1 >> > for a in range(y) >> > let z = a+1 >

Re: [Python-ideas] List assignment - extended slicing inconsistency

2018-02-23 Thread Chris Angelico
On Sat, Feb 24, 2018 at 5:24 AM, Chris Barker wrote: > On Thu, Feb 22, 2018 at 6:21 PM, Nick Coghlan wrote: >> >> > (I wonder if the discrepancy is due to some internal interface that >> > loses >> > the distinction between None and 1 before the decision is made whether >> > to >> > use advanced

Re: [Python-ideas] List assignment - extended slicing inconsistency

2018-02-23 Thread Serhiy Storchaka
23.02.18 20:50, Chris Angelico пише: Ignoring backward compatibility, it ought to be possible to (ab)use a stride of zero for this. Calling slice.indices() on something with a stride of zero raises ValueError, so there's no ambiguity. But it would break code that iterates in a simple and obvious

Re: [Python-ideas] List assignment - extended slicing inconsistency

2018-02-23 Thread Chris Angelico
On Sat, Feb 24, 2018 at 6:38 AM, Serhiy Storchaka wrote: > 23.02.18 20:50, Chris Angelico пише: >> >> Ignoring backward compatibility, it ought to be possible to (ab)use a >> stride of zero for this. Calling slice.indices() on something with a >> stride of zero raises ValueError, so there's no amb

Re: [Python-ideas] List assignment - extended slicing inconsistency

2018-02-23 Thread Nick Coghlan
On 24 February 2018 at 06:00, Chris Angelico wrote: > I presume it's already too late for 3.7 to change anything to fix this. > Yeah, any changes in relation to this would be 3.8+ only. To answer your previous question about "Wouldn't it be hard to fix this given the way slice processing works?