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

2018-05-26 Thread Michael Lohmann
> Right, which means that Pizza and Lasagna are not compatible classes > in that way. Okay, let me try it one final time with the original pizza example. Let’s assume that your restaurant has a special offer on all Hawaiian Pizzas where you can get all sizes for 10$. Now the only reasonable

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

2018-05-26 Thread Chris Angelico
On Sat, May 26, 2018 at 7:22 PM, Michael Lohmann wrote: > [Chris Angelico] >> Does that make sense? > Well yes, of course it does. When instantiating a HawaiianPizza of course you > want to set size and price. I don’t want to remove **kwargs and the current > way of

Re: [Python-ideas] ternary without else

2018-05-26 Thread Antoine Rozo
Dismiss my message, I have read `if "art_wt" not in article`. But in the same way, you could have a function to reset a value in your dict if the current value evaluates to False. 2018-05-26 11:21 GMT+02:00 Antoine Rozo : > > if not article["art_wt"]: article["art_wt"] =

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

2018-05-26 Thread Michael Lohmann
Let me put it this way: class A(object): def __init__(self, a_value, **kwargs): print("This is a value:", a_value) super().__init__(**kwargs) Which parameters does `A` take when being initialized? Whenever you give any kwargs when directly instantiating `A` they

Re: [Python-ideas] ternary without else

2018-05-26 Thread Antoine Rozo
> if not article["art_wt"]: article["art_wt"] = 0 > if not article["px_pchs"]: article["px_pchs"] = 0 > if not article["px_calc"]: article["px_calc"] = 0 > if not article["px_sell"]: article["px_sell"] = 0 I think what you need is the setdefault method of dictionnaries, instead of a new syntax

Re: [Python-ideas] "Assignment expression" with function call-alike syntax

2018-05-26 Thread Steven D'Aprano
On Sat, May 26, 2018 at 12:00:45PM +0300, Kirill Balunov wrote: > > It looks like a function you could call from anywhere, but you want > > to limit it to just "while" and "if", I expect that will just give us a > > flood of questions on Stackoverflow and other forums, "why can't I use > > this()

Re: [Python-ideas] "Assignment expression" with function call-alike syntax

2018-05-26 Thread Kirill Balunov
2018-05-24 4:21 GMT+03:00 Steven D'Aprano : > On Wed, May 23, 2018 at 12:32:36AM +0300, Kirill Balunov wrote: > > > Just one more variation on "assignment exression" syntax to make the list > > more complete :) Sorry, if something similar has already been suggested. > > The

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

2018-05-26 Thread Steven D'Aprano
On Sat, May 26, 2018 at 09:39:14AM +0200, Michael Lohmann wrote: > [Steven D'Aprano] > >obj = Aardvark(27, spam=3, eggs=5, cheese=True) > > > > So you look up help(Aardvark), and it tells you that the signature is > > > >Aardvark.__init__(self, foo) > > > > What the hell? If

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

2018-05-26 Thread Chris Angelico
On Sat, May 26, 2018 at 5:39 PM, Michael Lohmann wrote: > [Steven D'Aprano] >>obj = Aardvark(27, spam=3, eggs=5, cheese=True) >> >> So you look up help(Aardvark), and it tells you that the signature is >> >>Aardvark.__init__(self, foo) >> >> What the hell? If

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

2018-05-26 Thread Michael Lohmann
[Steven D'Aprano] >obj = Aardvark(27, spam=3, eggs=5, cheese=True) > > So you look up help(Aardvark), and it tells you that the signature is > >Aardvark.__init__(self, foo) > > What the hell? If Aardvark.__init__ only takes a single argument This is wrong! This would at some point down