Follow

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!

@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
Fosstodon

Fosstodon is an English speaking Mastodon instance that is open to anyone who is interested in technology; particularly free & open source software.