Declarations vs. statements (was Re: Dumb python questions)
Aahz Maruch
aahz at panix.com
Tue Aug 21 11:16:02 EDT 2001
In article <mailman.997933587.4901.python-list at python.org>,
Tim Peters <tim.one at home.com> wrote:
>Paul Rubin:
>>
>> Here's something I don't understand: why is it that the default
>> value of a function arg is evaluated just once, instead of whenever
>> the function is called?
>
>Simply because that seemed most useful most often, and is most consistent
>with the rest of the language: default arguments are a kind of binding
>performed at function definition time, and there are no instances of
>"delayed assignment" anywhere in the language. Note that "def" is an
>executable statement in Python, not a declaration ("class" is also
>executable, btw -- the only declaration in Python is the "global" stmt).
Hmmm? I would argue that "yield" (new in Python 2.2) is both an
executable statement and a declaration. In fact, that's precisely why
I argued against making yield alone the keyword for identifying a
generator.
--
--- Aahz <*> (Copyright 2001 by aahz at pobox.com)
Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/
Androgynous poly kinky vanilla queer het Pythonista
"I now regard a fact as a hypothesis that people don't bother to argue
about anymore." --John Burn, quoted in Lawrence Wright's _Twins_
More information about the Python-list
mailing list