Unexpected Python Behavior
David Bolen
db3l at fitlinxx.com
Thu Sep 30 13:59:32 EDT 2004
Greg Ewing <greg at cosc.canterbury.ac.nz> writes:
> Alex Martelli wrote:
> > I think it's in fact very nice syntax:
> > def f(x, cache=[]):
> > if x in cache: ...
>
> No, it's not, because it suggests that cache is
> intended to be an optional parameter, whereas it
> probably isn't.
Depends - I'd probably read that just as you say - it's an optional
parameter. But why assume it probably isn't intended that way. If I
want to use my own cache I pass it in, otherwise I expect the function
to have a default cache that it will use for me.
-- David
More information about the Python-list
mailing list