in reply to Re^5: Evolution of python
in thread Evolution of python

> Lexical variables and closures don't need each other,

a "closure" over a global variable is commonly known as a function using a global variable ...

IMHO that's far too trivial to be called a closure. :-p

Not sure why you are doing this

    arg = arg # make arg a lexical variable

arg should be a lexical var right away.

you might want to compare this, a is a lexical and clos a generated closure

>>> def test(a): ... def clos(): ... return a ... return clos ... >>> x=test(1) >>> y=test(22) >>> x() 1 >>> y() 22

This is pretty much a demonstration of lexical scope, you will only deal with dynamic scope when using global vars or accessing class attributes.*

Update

*) Well if functions call each other and close over the same lexical one might call this a dynamic scope too.

For instance a recursive closure.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice