I'm working with some code where a function takes a `date` parameter, and if no date is provided, calls Date.today _in the default argument constructor_.

The functional programmer in me finds that absolutely horrifying.

I'm not sure why calling an impure function in the argument constructor bothers me so much more than calling it in the body of the function would – but it sure does!

Follow

@codesections In Python default arguments are evaluated when the function is defined, so something like that would not actually be equivalent to calling it in the body.

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.