Is it explicitly specified?
auch-ich-m at g-kein-spam.com
Mon Feb 4 12:53:49 CET 2008
* 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
def g(foo, bar, x=None):
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.
Winnetous Erbe: <http://pub.perlig.de/books.html#apache2>
More information about the Python-list