loading...

Discussion on: 3 Tricky Python Nuances

Collapse
mexchip profile image
José Jorge

Good info!

I got caught by number 2 in my previous project, I was trying something like this:

def some_function(some_date = datetime.utcnow()):
    ...

I'd get the same date everytime some_function was called.

Changed to something like this:

def some_function(some_date = None):
    if some_date is None:
        some_date = datetime.utcnow()

    ...
Collapse
codemouse92 profile image
Jason C. McDonald

Oof, that's a keeper!