FAQ
Hi!

I marked it with the word "misfeature", but of course I meant only the
problem with mutable types. Sure, I use
lambda x, y=z: ...
often.
(But that's another problem. After 10 years with Pascal, I used to use
local functions, that have access to outer function's variables. Learning
to use lambdas was a little pain for me. And I still hope Python will have
local functions sometime... may be 2.0+)
On Sun, 17 Oct 1999, Fredrik Lundh wrote:
Mmm??? Are there a line of code that *relies* on that misfeature?
yes, there are tons of code that relies on the
fact that the default values are evaluated once,
and more importantly, that they are evaluated
in the namespace where the function/lambda
is defined.

in fact, it's currently the only reasonable way
to pass local variables into a nested namespace
(like when using lambdas). it's also often used
to speed things up, by binding commonly used
globals to local names.
but sure, I'm sure Guido is open for proposals. I
don't think you can get away with "always evaluate
them on each call," though...
Oleg.
----
Oleg Broytmann National Research Surgery Centre http://sun.med.ru/~phd/
Programmers don't die, they just GOSUB without RETURN.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 7 of 12 | next ›
Discussion Overview
grouppython-list @
categoriespython
postedOct 17, '99 at 12:47a
activeOct 27, '99 at 7:30p
posts12
users6
websitepython.org

People

Translate

site design / logo © 2021 Grokbase