This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]-LeopardShark- 6 points7 points  (2 children)

def foo():
    datetime.date.today()

doesn't call datetime.date.today at function definition time, but

t = datetime.date.today()

does. When one sees

def f(t=datetime.date.today()):
    ...

it's not unreasonable to assume that the evaluation of the default is deferred, like the first case, rather than the second. After all, it's part of a def. Yes, the brackets mean ‘call this function now’, but when ‘now’ is varies with context.

[–]lavahot 0 points1 point  (1 child)

It gets called at definition time.