function argument dependent on another function argument?
Paul Rubin
http
Sun Jan 18 10:36:53 EST 2009
Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> writes:
> def foo(self, x, y=None):
> if y is None:
> y = self.a
>
> I don't find that clumsy in the least. I find it perfectly readable and a
> standard idiom.
That has the same problem as the earlier version. If the person
passes None, they get self.a. I prefer:
sentinel = object()
...
def foo(x, y=sentinel):
if y is sentinel:
y = self.a
More information about the Python-list
mailing list