On Dec 31, 10:58 am, Odalrick <[EMAIL PROTECTED]> wrote:
> On 30 Dec, 17:26, George Sakkis <[EMAIL PROTECTED]> wrote:
>
> > On Dec 29, 9:14 pm, bukzor <[EMAIL PROTECTED]> wrote:
>
> > > Here's the answer to the 
> > > question:http://www.python.org/doc/faq/general/#why-are-default-values-shared-...
>
> > > It looks like Guido disagrees with me, so the discussion is closed.
>
> > Note that the FAQ mainly explains *what* happens, not *why* was this
> > decision taken. Although it shows an example where "this feature can
> > be useful", it's neither the only way to do it nor is memoization as
> > common as wanting fresh default arguments on every call.
>
> I'm surprised noone has said anything about the why of default
> mutables. I think it is becasue it isn't easy to do it an other way.

[...]

There is an easy enough way: evaluate default values when the function
is called rather than when it is defined.  This behaviour comes with
its own caveats as well I imagine, and it's not 'as easy' to implement
as the current one.

What's good about the current behaviour is that it is easy to reason
with (once you know what happens), even though you almost have to get
bitten once.  But using this to have static variable is extremely ugly
IMHO.

--
Arnaud

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to