http://boodebr.org/main/python/tourist/mutable-obj-as-default-arg
"Many modern languages allow for default function arguments. Default arguments can be a great thing - they allow you to use sensible defaults for the common cases, without taking away the power to add more functionality as needed. You can arbitrarily expand a function definition without breaking existing code by providing sensible defaults for the new parameters.
Here is a fun example of how Python will bite you if you try to use a mutable object (like a list, dict, or object instance) as a default argument. The following is an example function I'm trying to write ..."
0 comments:
Post a Comment