more pythonic way

Jimmy Girardet ijkl at netc.fr
Mon Feb 11 14:48:44 EST 2019


The first one is used very often. Less verbose

Le 11 févr. 2019 à 20:41, à 20:41, Felix Lazaro Carbonell <felix at epepm.cupet.cu> a écrit:
> 
>
>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 datetime.date.today()
>
>..
>
> 
>
>Or it should better be:
>
>...
>
>        if not month:
>
>            month = datetime.date.today()
>
>..
>
> 
>
>Cheers,
>
>Felix.
>
> 
>
>-- 
>https://mail.python.org/mailman/listinfo/python-list



More information about the Python-list mailing list