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.. 
                

> On Dec 16, 2020, at 6:14 PM, Steven D'Aprano <st...@pearwood.info> wrote:
> 
> def method(self, spam, eggs, cheese, tomato, aardvark):
>        if spam is None: spam = self.spam
>        if eggs is None: eggs = self.eggs
>        # etc

_______________________________________________
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/Y2I6IFZ5RCHDUZ7VUWMZLI3PMVXY6PZZ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to