osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

more pythonic way


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