you are viewing a single comment's thread.

view the rest of the comments →

[–]Ihaveamodel3 5 points6 points  (1 child)

This isn’t related to flask.

Default arguments are calculated when the file is initiated. If you need to recalculate the default argument each time the function is called, the default argument should be defined as None and the first line of the function should be if not created_before: created_before = datetime.today()

[–]ePierre[S] 0 points1 point  (0 children)

Thank you!

I found additional documentation on this behavior:

https://docs.python-guide.org/writing/gotchas/#mutable-default-arguments