[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 t
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 Aardvark.__init__ only takes a
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 Aardvark.__i
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 idea is to use function
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()
> 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 con
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
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"] = 0
> > if not article["px_
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 handeling this. But if you no
> 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 thi
On 2018-05-26 02:22, Michael Lohmann wrote:
Whenever you give any kwargs when directly instantiating `A` they
will be passed down to super which in this case is `object`. And now
to the follow-up question: Can you tell me which kwargs object takes
as an input for it’s __init__? So does it EVER ma
11 matches
Mail list logo