Bizarre method keyword-arg bug.
steve at REMOVE-THIS-cybersource.com.au
Mon Aug 18 16:23:20 CEST 2008
On Mon, 18 Aug 2008 04:07:14 -0700, Paul Boddie wrote:
> Ultimately, I suppose one could enforce some kind of least surprising
> "best practice" by limiting default parameter values to being literals
> of immutable objects or names, as opposed to expressions, thus
> eliminating some potential confusion.
Firstly, I *like* the ability to use mutable objects as default
arguments. I don't do it often, but when I do, I do it deliberately. I
find it useful.
Secondly, I think forbidding expressions as default arguments would be
far worse than the so-called "problem" you wish to fix. It would make
such simple default arguments as these unnecessarily complicated:
def foo(x=2**64, sentinel=object())
Please don't try to "fix" this feature.
More information about the Python-list