About Callable Function Arguments
Using callable()
you can allow a function to accept either values or functions that return values. Here is an example of the pattern:
from datetime import datetime
def do_something(timestamp=datetime.now):
if callable(timestamp):
timestamp = timestamp()
print(timestamp)
Also by me
Django Paddle Subscriptions app
For Django-based SaaS projects.
Django App for You
Django GDPR Cookie Consent app
For Django websites that use cookies.
Django App for You