Re: [Python-ideas] Keyword for direct pass through of kwargs to super

2018-05-25 Thread Steven D'Aprano
On Sat, May 26, 2018 at 02:06:40AM +0200, Michael Lohmann wrote: > I propose to add some mechanism that can automatically collect everything > what would normally be collected by **kwargs in the __init__ method and > directly pass it through to the super().__init__ call without being > accessible

Re: [Python-ideas] Keyword for direct pass through of kwargs to super

2018-05-25 Thread Carl Smith
> But the user could have had the false impression that additional kwargs > could be given when instantiating A. Obviously they are purely there for > getting the init in the MRO working with multiple inheritance. This just isn't true. You often do things with the kargs before passing them or

Re: [Python-ideas] ternary without else

2018-05-25 Thread Carl Smith
​You cannot have `expression if expression` in a language that also supports `expression if expression else expression` (like Python).​ Otherwise, you have the dangling else problem: https://en.wikipedia.org/wiki/Dangling_else -- Carl Smith carl.in...@gmail.com On 25 May 2018 at 15:21, Rob

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

2018-05-25 Thread Tim Peters
[Peter O'Connor] >> ... >> We could use given for both the in-loop variable update and the variable >> initialization: >>smooth_signal = [average given average=(1-decay)*average + decay*x >> for x in signal] given average=0. [Steven D'Aprano

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

2018-05-25 Thread Mark E. Haase
asyncio.coroutine and async def are slightly different—not synonyms. The former defines a generator function and the latter defines a coroutine function. Generators and coroutines are very similar in Python (they share lots of code in the CPython implementation) but coroutines are preferred for

Re: [Python-ideas] ternary without else

2018-05-25 Thread Rob Cliffe via Python-ideas
On 25/05/2018 12:38, Steven D'Aprano wrote: PEP 8 is not holy writ. Ignore it when your code is better for ignoring it. +1.  Not infrequently I judge that my code is easier both to read and to maintain with more than 1 (short) statement on a line, often when it allows similar items to be

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

2018-05-25 Thread Rob Cliffe via Python-ideas
On 24/05/2018 16:54, 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 comprehensions.  This can be

Re: [Python-ideas] ternary without else

2018-05-25 Thread Jacco van Dorp
2018-05-25 14:57 GMT+02:00 Elazar : > The title is misleading - this has nothing to do with the conditional > operator, except small syntactic similarity. On second look, yeah, you're right. ___ Python-ideas mailing list

Re: [Python-ideas] ternary without else

2018-05-25 Thread Steven D'Aprano
On Fri, May 25, 2018 at 12:06:42PM +0200, Jacco van Dorp wrote: > I would like to carefully suggest a half form of the ternary expression. [...] > However, this isn't PEP8 compliant PEP 8 is not holy writ. Ignore it when your code is better for ignoring it. > I would very much like to write: >

Re: [Python-ideas] ternary without else

2018-05-25 Thread Elazar
The title is misleading - this has nothing to do with the conditional operator, except small syntactic similarity. Elazar בתאריך יום ו׳, 25 במאי 2018, 05:40, מאת Jacco van Dorp ‏< j.van.d...@deonet.nl>: > 2018-05-25 14:26 GMT+02:00 Kirill Balunov : > > If it is an

Re: [Python-ideas] ternary without else

2018-05-25 Thread Jacco van Dorp
2018-05-25 14:26 GMT+02:00 Kirill Balunov : > If it is an expression, what should `do_something if cond` return on > failure? If you don't care you can already use `cond and do_something`. Duh, forgot to mention. I wouldn't have it return anything. Ternary returns

Re: [Python-ideas] ternary without else

2018-05-25 Thread Kirill Balunov
2018-05-25 13:06 GMT+03:00 Jacco van Dorp : > [...] > > I would very much like to write: > > >>> do_something if cond > > and be done with it. Like a ternary expression but without the else clause. > > If it is an expression, what should `do_something if cond` return on

Re: [Python-ideas] ternary without else

2018-05-25 Thread Philipp A.
in jinja, you can do “{{ 'foo' if bar }}”. it evaluates to “'foo'” or an empty string (differently to python’s formatting, “None” expands to an empty string in jinja) similarly I often do “thing = 'foo' if bar else None” and it would be nice if i could shorten that by making “else None”

Re: [Python-ideas] ternary without else

2018-05-25 Thread Serhiy Storchaka
25.05.18 13:06, Jacco van Dorp пише: I would like to carefully suggest a half form of the ternary expression. Currently, you can write code like: if cond: do_something However, especially if the condition and action are both really simple, taking two lines feels like a bit of a waste.

[Python-ideas] ternary without else

2018-05-25 Thread Jacco van Dorp
I would like to carefully suggest a half form of the ternary expression. Currently, you can write code like: >>> if cond: >>>do_something However, especially if the condition and action are both really simple, taking two lines feels like a bit of a waste. So I sometimes write: >>> if cond:

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

2018-05-25 Thread João Santos
Hi, You can use uvloop , for example, without using asyncio: import uvloop loop = uvloop.new_event_loop() loop.run_forever() Best regards, João Santos On Fri, 25 May 2018 at 02:42, Ken Hilton wrote: > On Tue May 22 22:08:40