[Python-ideas] Thoughts on "extended mapping unpacking"

2018-05-24 Thread Neil Girdhar
I was previously constructing an object like this: tb = TemporalBehavior(**kwargs, **parameters) where various subclasses were doing things like def __init__(self, some_kwarg, some_other_kwargs, some_parameter, some_other_parameter): Then I realized that I want to pass the paramters as a dicti

Re: [Python-ideas] Thoughts on "extended mapping unpacking"

2018-05-24 Thread Serhiy Storchaka
24.05.18 11:38, Neil Girdhar пише: I was previously constructing an object like this: tb = TemporalBehavior(**kwargs, **parameters) where various subclasses were doing things like def __init__(self, some_kwarg, some_other_kwargs, some_parameter, some_other_parameter): Then I realized that I

Re: [Python-ideas] Proposal: A Reduce-Map Comprehension and a "last" builtin

2018-05-24 Thread Peter O'Connor
To give this old horse a kick: The "given" syntax in the recent thread could give a nice solution for the problem that started this thread. Instead of my proposal of: smooth_signal = [average := (1-decay)*average + decay*x for x in signal from average=0.] We could use given for both the in-loo

Re: [Python-ideas] Proposal: A Reduce-Map Comprehension and a "last" builtin

2018-05-24 Thread Steven D'Aprano
On Thu, May 24, 2018 at 02:06:03PM +0200, Peter O'Connor wrote: > To give this old horse a kick: The "given" syntax in the recent thread > could give a nice solution for the problem that started this thread. Your use-case is one of the motivating examples for PEP 572. Unless I'm confused, your us

Re: [Python-ideas] Thoughts on "extended mapping unpacking"

2018-05-24 Thread Neil Girdhar
On Thu, May 24, 2018 at 8:00 AM Serhiy Storchaka wrote: > 24.05.18 11:38, Neil Girdhar пише: > > I was previously constructing an object like this: > > > > tb = TemporalBehavior(**kwargs, **parameters) > > > > where various subclasses were doing things like > > > > def __init__(self, some_kwarg,

[Python-ideas] Reuse "for" to express "given"

2018-05-24 Thread Alexander Belopolsky
I have read most of the PEP 572 related threads, but I don't think I've seen this idea. As many other people mentioned, Python already allows a trick to introduce local bindings in generator expressions and list comprehensions. This can be achieved by adding a "for var in []" clause. I propose t

Re: [Python-ideas] Reuse "for" to express "given"

2018-05-24 Thread Robert Vanden Eynde
This idea was mentioned (by me) at a time yes, but wasn't written in the document. I think one of the thing was that it would make the grammar non LL1 because when seeing the token "for" in a list comprehension it wouldn't know in advance if it's the loop or the assignment. And also, it might con

Re: [Python-ideas] Reuse "for" to express "given"

2018-05-24 Thread Alexander Belopolsky
On Thu, May 24, 2018 at 12:04 PM Robert Vanden Eynde wrote: > This idea was mentioned (by me) at a time yes, but wasn't written in the document. Can you point me to a specific post? There were so may that I must have missed that one. > I think one of the thing was that it would make the gramma

Re: [Python-ideas] Reuse "for" to express "given"

2018-05-24 Thread Robert Vanden Eynde
It was a long time ago I couldn't easily find the post but that's alright, you refreshed the idea :) Let's see what others think of for x = I also remembered some languages (like lua) use for x = range (5) interchangeably with for x in range (5) and guido said it will never make such a thing, for

Re: [Python-ideas] Thoughts on "extended mapping unpacking"

2018-05-24 Thread Serhiy Storchaka
24.05.18 18:46, Neil Girdhar пише: p = parameters.pop('some_parameter') q = parameters.pop('some_other_parameter') if parameters:      raise ValueError parameters is a Mapping subclass and I don't want to destroy it Oh, right. It works if parameters is a var-keyword parameter.

Re: [Python-ideas] Reuse "for" to express "given"

2018-05-24 Thread Serhiy Storchaka
24.05.18 18:54, Alexander Belopolsky пише: I have read most of the PEP 572 related threads, but I don't think I've seen this idea.  As many other people mentioned, Python already allows a trick to introduce local bindings in generator expressions and list comprehensions.  This can be achieved b

Re: [Python-ideas] Reuse "for" to express "given"

2018-05-24 Thread George Leslie-Waksman
I worry about the use of "for" because it will come up in contexts where "for" already has other meanings. In the case of the example list comprehension, the word "for" is being used to mean two entirely different things in a single expression, that seems rather precarious to me. I prefer "with" i

Re: [Python-ideas] Thoughts on "extended mapping unpacking"

2018-05-24 Thread George Leslie-Waksman
I have had plenty of instances where destructuring a mapping would have be convenient. Relating to iterable destructuring, I would expect the syntax to be of the form "variable: key". I also think the curly-braces make it harder to visually parse what's going on. So I might suggest something a litt

Re: [Python-ideas] Thoughts on "extended mapping unpacking"

2018-05-24 Thread MRAB
On 2018-05-24 18:08, George Leslie-Waksman wrote: I have had plenty of instances where destructuring a mapping would have be convenient. Relating to iterable destructuring, I would expect the syntax to be of the form "variable: key". I also think the curly-braces make it harder to visually pars

Re: [Python-ideas] Reuse "for" to express "given"

2018-05-24 Thread Steven D'Aprano
On Thu, May 24, 2018 at 11:54:09AM -0400, Alexander Belopolsky wrote: > I have read most of the PEP 572 related threads, but I don't think I've > seen this idea. As many other people mentioned, Python already allows a > trick to introduce local bindings in generator expressions and list > comprehe

[Python-ideas] Mashup the existing statement grammars to capture predicates

2018-05-24 Thread Carl Smith
This is another suggestion for new syntax for assigning a name to the value of the predicate in an if, elif or while statement. It still uses `as` for its keyword, but with (more flexible) params instead of a direct assignment. It mashes up the if/while, def/class and for-in grammars, so it still

Re: [Python-ideas] Reuse "for" to express "given"

2018-05-24 Thread Alexander Belopolsky
> But I do have a mathematics background, and I don't remember ever seeing > "for x = value" used in the sense you mean. That's so because in mathematics, "for" is spelled ":" as in {2*a* : *a*∈*Z*} If you can read the above, you should not have trouble reading {2*a* + *b* : *a*∈*Z *: *b = *1

Re: [Python-ideas] Reuse "for" to express "given"

2018-05-24 Thread Matt Arcidy
On Thu, May 24, 2018, 11:47 Alexander Belopolsky < alexander.belopol...@gmail.com> wrote: > > But I do have a mathematics background, and I don't remember ever seeing > > "for x = value" used in the sense you mean. > > That's so because in mathematics, "for" is spelled ":" as in > > {2*a* : *a*∈*

Re: [Python-ideas] Reuse "for" to express "given"

2018-05-24 Thread Alexander Belopolsky
On Thu, May 24, 2018 at 4:59 PM Matt Arcidy wrote: > > > On Thu, May 24, 2018, 11:47 Alexander Belopolsky < > alexander.belopol...@gmail.com> wrote: > >> > But I do have a mathematics background, and I don't remember ever >> seeing >> > "for x = value" used in the sense you mean. >> >> That's so

Re: [Python-ideas] Make asyncio.get_event_loop a builtin

2018-05-24 Thread Ken Hilton
On Tue May 22 22:08:40 (-0400), Chris Barker wrote: > while asyncio is in the standard library, it is not intended to be THE async event loop implementation I'm surprised this is true - with dedicated syntax like async def/await, it's still not THE async event loop implementation? As far as I know

Re: [Python-ideas] Reuse "for" to express "given"

2018-05-24 Thread Matt Arcidy
On Thu, May 24, 2018, 14:48 Alexander Belopolsky < alexander.belopol...@gmail.com> wrote: > > > On Thu, May 24, 2018 at 4:59 PM Matt Arcidy wrote: > >> >> >> On Thu, May 24, 2018, 11:47 Alexander Belopolsky < >> alexander.belopol...@gmail.com> wrote: >> >>> > But I do have a mathematics backgroun