[Python-ideas] Default arguments in Python - the return - running out of ideas but...
Steven D'Aprano
steve at pearwood.info
Fri May 15 11:08:57 CEST 2009
On Fri, 15 May 2009 04:13:23 pm Chris Rebert wrote:
> +1 on throwing a ValueError for non-hash()-able (and thus probably
> mutable) default argument values.
You're not serious are you? What could possibly be either surprising or
objectionable about a function like this?
def f(data,substitutions = {}):
...
name = data['name']
obj.name = substitutions.get(name,name)
...
Example taken from:
http://mail.python.org/pipermail/python-list/2008-August/504811.html
--
Steven D'Aprano
More information about the Python-ideas
mailing list