Invisible function attributes
Olivier Lefevre
lefevrol at yahoo.com
Thu Sep 4 10:27:51 EDT 2003
Thanks to all those who replied.
> ...what I'm guessing you haven't figured out yet is that everything
> works like this in Python.
Very possibly. I am coming to python from Java and I want to investigate
the weird stuff precisely because either it's a one-off (in which case
I'll make a note to myself to ignore it and not use it) or it holds the
key to what is specific about the language. I seem to have hit pay dirt
with this one ;-)
Nudged by the dot syntax, I was thinking of this function attribute as
if it were a sort of class member (i.e., pretending for a while this
function is a class) and, since functions can't have instances, treating
it as a sort of static member of the function, which should be available
as soon as declared. Obviously I got it all wrong. Instead, they work
like local variables except that they "persist" after the function has
exited. That still feels weird to me. What are they used for? Give me
a compelling reason to have such a beast in the language.
OTOH, does this behaviour have anything to do with so-called "futures"?
-- O.L.
More information about the Python-list
mailing list