* Steven D'Aprano wrote: > On Sun, 03 Feb 2008 15:31:49 -0800, Paul Boddie wrote: > >> I don't know whether I can offer much better advice than others, but I >> have noticed that a lot of my own code has moved in the direction of not >> having specific default values in function/method signatures. So, >> instead of this... >> >> def f(x=123): >> ... >> >> ...I have this: >> >> def f(x=None): >> if x is None: >> x = 123 > > > For the love of Pete, WHY?????? > > I understand why you would do it for a mutable default, but immutable???
I'm observing myself doing the same, for the following reason: Consider the function being part of a bigger system, where it's called from another function or method which should "inherit" the default value of the function, like: def g(foo, bar, x=None): ... f(x=x) Now if you change the default value of f(x) for some reason, you don't have to wind up all the possible caller signatures to reflect that change. nd -- Winnetous Erbe: <http://pub.perlig.de/books.html#apache2> -- http://mail.python.org/mailman/listinfo/python-list