Re: [Python-ideas] Fwd: unpacking generalisations for list comprehension

2016-10-26 Thread Sjoerd Job Postmus
On Thu, Oct 27, 2016 at 03:27:07AM +1100, Steven D'Aprano wrote: > I think that there is zero hope of consistency for * the star operator. > That horse has bolted. It is already used for: > > - ... > - "zero or more of the previous element" in regular expressions > - "zero or more of any

Re: [Python-ideas] Fwd: unpacking generalisations for list comprehension

2016-10-25 Thread Rob Cliffe
On 14/10/2016 07:00, Greg Ewing wrote: Neil Girdhar wrote: At the end of this discussion it might be good to get a tally of how many people think the proposal is reasonable and logical. I think it's reasonable and logical. I concur. Two points I personally find in favour, YMMV: (1)

Re: [Python-ideas] Fwd: unpacking generalisations for list comprehension

2016-10-16 Thread Steven D'Aprano
On Sat, Oct 15, 2016 at 05:38:15PM +, Neil Girdhar wrote: > In ast.c, you can find: > > if (is_dict) { > ast_error(c, n, "dict unpacking cannot be used in " > "dict comprehension"); > return NULL; >

Re: [Python-ideas] Fwd: unpacking generalisations for list comprehension

2016-10-15 Thread Steven D'Aprano
On Thu, Oct 13, 2016 at 01:30:45PM -0700, Neil Girdhar wrote: > From a CPython implementation standpoint, we specifically blocked this code > path, and it is only a matter of unblocking it if we want to support this. I find that difficult to believe. The suggested change seems like it should

Re: [Python-ideas] Fwd: unpacking generalisations for list comprehension

2016-10-14 Thread Greg Ewing
Neil Girdhar wrote: At the end of this discussion it might be good to get a tally of how many people think the proposal is reasonable and logical. I think it's reasonable and logical. -- Greg ___ Python-ideas mailing list Python-ideas@python.org

Re: [Python-ideas] Fwd: unpacking generalisations for list comprehension

2016-10-13 Thread David Mertz
I've never used nor taught a * in a list display. I don't think they seem so bad, but it's a step down a slippery slope towards forms that might as well be Perl. On Oct 13, 2016 10:33 PM, "Greg Ewing" wrote: > David Mertz wrote: > >> it would always be "Here's a

Re: [Python-ideas] Fwd: unpacking generalisations for list comprehension

2016-10-13 Thread Greg Ewing
David Mertz wrote: it would always be "Here's a Python wart to look out for if you see it in other code... you should not ever use it yourself." Do you currently tell them the same thing about the use of * in a list display? -- Greg ___ Python-ideas

Re: [Python-ideas] Fwd: unpacking generalisations for list comprehension

2016-10-13 Thread David Mertz
Exactly with Paul! As I mentioned, I teach software developers and scientists Python for a living. I get paid a lot of money to do that, and have a good sense of what learners can easily understand and not (I've also written hundred of articles and a few books about Python). The people I write

Re: [Python-ideas] Fwd: unpacking generalisations for list comprehension

2016-10-13 Thread Steven D'Aprano
On Thu, Oct 13, 2016 at 03:28:27PM +, אלעזר wrote: > It may also suggest that there are currently two ways to understand the > *[...] construct, This thread is about allowing sequence unpacking as the internal expression of list comprehensions: [ *(expr) for x in iterable ] It isn't

Re: [Python-ideas] Fwd: unpacking generalisations for list comprehension

2016-10-13 Thread Paul Moore
On 13 October 2016 at 15:32, Sven R. Kunze wrote: > Steven, please. You seemed to struggle to understand the notion of the > [*] construct and many people (not just me) here tried their best to > explain their intuition to you. And yet, the fact that it's hard to explain

Re: [Python-ideas] Fwd: unpacking generalisations for list comprehension

2016-10-13 Thread Sven R. Kunze
On 13.10.2016 16:10, Steven D'Aprano wrote: On Thu, Oct 13, 2016 at 10:37:35AM +0200, Sven R. Kunze wrote: Multiplication with only a single argument? Come on. You didn't say anything about a single argument. Your exact words are shown above: "where have I seen * so far?". I'm pretty sure

Re: [Python-ideas] Fwd: unpacking generalisations for list comprehension

2016-10-13 Thread אלעזר
On Thu, Oct 13, 2016 at 5:10 PM Steven D'Aprano wrote: > On Thu, Oct 13, 2016 at 10:37:35AM +0200, Sven R. Kunze wrote: > > About the list constructor: we construct a list by writing [a,b,c] or by > > writing [b for b in bs]. The end result is a list > > I construct lists

Re: [Python-ideas] Fwd: unpacking generalisations for list comprehension

2016-10-13 Thread Steven D'Aprano
On Thu, Oct 13, 2016 at 10:37:35AM +0200, Sven R. Kunze wrote: > On 13.10.2016 01:29, Steven D'Aprano wrote: > >On Wed, Oct 12, 2016 at 06:32:12PM +0200, Sven R. Kunze wrote: > >> > >>So, my reasoning would tell me: where have I seen * so far? *args and > >>**kwargs! > >And multiplication. > >

Re: [Python-ideas] Fwd: unpacking generalisations for list comprehension

2016-10-13 Thread Sven R. Kunze
On 13.10.2016 01:29, Steven D'Aprano wrote: On Wed, Oct 12, 2016 at 06:32:12PM +0200, Sven R. Kunze wrote: So, my reasoning would tell me: where have I seen * so far? *args and **kwargs! And multiplication. Multiplication with only a single argument? Come on. And sequence unpacking. We

Re: [Python-ideas] Fwd: unpacking generalisations for list comprehension

2016-10-12 Thread אלעזר
On Thu, Oct 13, 2016 at 2:35 AM Steven D'Aprano wrote: > On Wed, Oct 12, 2016 at 04:11:55PM +, אלעזר wrote: > > > Steve, you only need to allow multiple arguments to append(), then it > makes > > perfect sense. > > I think you're missing a step. What will multiple

Re: [Python-ideas] Fwd: unpacking generalisations for list comprehension

2016-10-12 Thread Steven D'Aprano
On Wed, Oct 12, 2016 at 04:11:55PM +, אלעזר wrote: > Steve, you only need to allow multiple arguments to append(), then it makes > perfect sense. I think you're missing a step. What will multiple arguments given to append do? There are two obvious possibilities: - collect all the arguments

Re: [Python-ideas] Fwd: unpacking generalisations for list comprehension

2016-10-12 Thread Steven D'Aprano
On Wed, Oct 12, 2016 at 06:32:12PM +0200, Sven R. Kunze wrote: > On 12.10.2016 17:41, Nick Coghlan wrote: > >This particular proposal fails on the first question (as too many > >people would expect it to mean the same thing as either "[*expr, for > >expr in iterable]" or "[*(expr for expr in

Re: [Python-ideas] Fwd: unpacking generalisations for list comprehension

2016-10-12 Thread אלעזר
To be honest, I don't have a clear picture of what {**x for x in d.items()} should be. But I do have such picture for dict(**x for x in many_dictionaries) Elazar ‪On Wed, Oct 12, 2016 at 11:37 PM ‫אלעזר‬‎ wrote:‬ > On Wed, Oct 12, 2016 at 11:26 PM David Mertz

Re: [Python-ideas] Fwd: unpacking generalisations for list comprehension

2016-10-12 Thread Sven R. Kunze
On 12.10.2016 21:38, אלעזר wrote: What is the intuition behind [1, *x, 5]? The starred expression is replaced with a comma-separated sequence of its elements. The trailing comma Nick referred to is there, with the rule that [1,, 5] is the same as [1, 5]. I have to admit that I have my

Re: [Python-ideas] Fwd: unpacking generalisations for list comprehension

2016-10-12 Thread Paul Moore
On 12 October 2016 at 20:22, David Mertz wrote: > I've followed this discussion some, and every example given so far > completely mystifies me and I have no intuition about what they should mean. Same here. On 12 October 2016 at 20:38, אלעזר wrote: > What is

Re: [Python-ideas] Fwd: unpacking generalisations for list comprehension

2016-10-12 Thread David Mertz
On Wed, Oct 12, 2016 at 12:38 PM, אלעזר wrote: > What is the intuition behind [1, *x, 5]? The starred expression is > replaced with a comma-separated sequence of its elements. > I've never actually used the `[1, *x, 5]` form. And therefore, of course, I've never taught it

Re: [Python-ideas] Fwd: unpacking generalisations for list comprehension

2016-10-12 Thread אלעזר
What is the intuition behind [1, *x, 5]? The starred expression is replaced with a comma-separated sequence of its elements. The trailing comma Nick referred to is there, with the rule that [1,, 5] is the same as [1, 5]. All the examples follow this intuition, IIUC. Elazar בתאריך יום ד׳, 12

Re: [Python-ideas] Fwd: unpacking generalisations for list comprehension

2016-10-12 Thread אלעזר
Steve, you only need to allow multiple arguments to append(), then it makes perfect sense. בתאריך יום ד׳, 12 באוק' 2016, 18:43, מאת Steven D'Aprano ‏< st...@pearwood.info>: > On Tue, Oct 11, 2016 at 02:42:54PM +0200, Martti Kühne wrote: > > Hello list > > > > I love the "new" unpacking

Re: [Python-ideas] Fwd: unpacking generalisations for list comprehension

2016-10-12 Thread Nick Coghlan
On 12 October 2016 at 23:58, Sven R. Kunze wrote: > Reading PEP448 it seems to me that it's already been considered: > https://www.python.org/dev/peps/pep-0448/#variations > > The reason for not-inclusion were about concerns about acceptance because of > "strong concerns about