more pythonic way

David Raymond David.Raymond at
Mon Feb 11 15:15:29 EST 2019

My non-expert vote is for

if month is None:
    month =

Because you're checking for your default value, not whether the boolean version of what they did give you is True or False. It's explicit, it's not reliant on any __bool__() function implementations or overrides, etc.

-----Original Message-----
From: Python-list [ at] On Behalf Of Felix Lazaro Carbonell
Sent: Monday, February 11, 2019 2:30 PM
To: python-list at
Subject: more pythonic way


Hello to everyone:

Could you please tell me wich way of writing this method is more pythonic:



    def find_monthly_expenses(month=None, year=None):

        month = month or



Or it should better be:


        if not month:

            month =







More information about the Python-list mailing list