In that case:
        spam = spam if spam is not None else self.spam
The “or” won’t work with zero. 

> On Dec 16, 2020, at 11:00 PM, Marco Sulla <marco.sulla.pyt...@gmail.com> 
> wrote:
> 
> On Wed, 16 Dec 2020 at 19:52, Abdulla Al Kathiri
> <alkathiri.abdu...@gmail.com> wrote:
>> 
>> Or more concise
>> def method(self, spam, eggs, cheese, *args):
>> spam = spam or self.spam
>> eggs = eggs or self.eggs
>> #etc., The above is equivelent to the following:
>> spam = spam if spam else self.spam
>> eggs = eggs if eggs else self.eggs
>> # I prefer the first approach..
> 
> What if spam, for example, is zero?
> _______________________________________________
> Python-ideas mailing list -- python-ideas@python.org
> To unsubscribe send an email to python-ideas-le...@python.org
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at 
> https://mail.python.org/archives/list/python-ideas@python.org/message/2R5BBCBNA6ITHLNSSZYUQPCSGJLY44RT/
> Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/34D7FXYE627QPBKEEHZVSMAWOUYB3EZO/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to