Ka-Ping Yee <python-dev at zesty.ca> wrote: > Most other languages that support lexical scoping (including Scheme, > JavaScript, Ruby, Perl, E, Java, Smalltalk) provide a uniform way > to read and write to scopes at all levels. This is done by letting > programmers specify the scope in which they want a variable bound > (usually with a keyword like "var" in JavaScript, "my" in Perl, or > "define" in E). That's not the Python way, IMO. I think the right way (assuming we actually want to allow it) is to introduce a pure assignment statement in addition to the assignment/declaration statement that we already have. For example: a = 1 def f(): b = 2 a := 2 def g(): b := 3 print a, b, c g() f() would print "2 3 4". The := would assign but not declare a variable in the current scope. Neil
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4