in reply to Re^4: Evolution of python
in thread Evolution of python
Lexical variables and closures don't need each other, unless you define a closure as something that closes over its lexical variables.
x = "Hello"; # a global variable def make_closure(arg): arg = arg # make arg a lexical variable return lambda y, arg=arg: print(x,y,arg)
The indentation or braces are (mostly) equivalent in defining where a name/value binding may be visible, but that has nothing to do with closures.
And the OP issue of not knowing where/how a variable can be declared limited to a scope isn't an issue IMO because both Perl and Python have variables with limited scope which aren't visible "upwards".
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^6:Evolution of python
by LanX (Saint) on Jul 07, 2019 at 19:52 UTC |