payu-org / payu

A workflow management tool for numerical models on the NCI computing systems
Apache License 2.0
20 stars 26 forks source link

Avoid mutable default parameters #177

Closed kinow closed 5 years ago

kinow commented 5 years ago

Hi!

Small change to prevent unwanted behaviour for add_fast. https://docs.quantifiedcode.com/python-anti-patterns/correctness/mutable_default_value_as_argument.html

Cheers

aidanheerdegen commented 5 years ago

Thanks @kinow. I agree your change is a good one, but for anyone following along at home I don't believe the existing code leads to any unintended behaviour, as the way this routine is currently used is quite limited.

Are you evaluating payu for running models, or just taking an interest?

kinow commented 5 years ago

The latter. Agree it is harmless, and all good if not merged :-) it was for the just in case

marshallward commented 5 years ago

I agree it'sa good idea to avoid mutables as inputs, even if there's no real danger in this case.

@aidanheerdegen if you're happy to merge then no objections from me.

aidanheerdegen commented 5 years ago

Didn't merge until replies were in, seemed rude otherwise .. :)