Just van Rossum wrote: > Why couldn't at least augmented assignment be implicitly rebinding? It > has been suggested before (in the context of a rebinding operator), but > I'm wondering, is this also off the table? > > def counter(num): > def inc(): > num += 1 > return num > return inc > > Reads very natural to me. It's likely the most frequent example of what > people try before they learn that rebinding to outer scopes isn't > allowed. It could Just Work. note that most examples of this type already work, if the target type is mutable, and implement the right operations: def counter(num): num = mutable_int(num) def inc(): num += 1 return num return inc maybe we should consider adding mutable strings and mutable numbers to Python 3.0 ? and a "mutable" built-in, that does the opposite of the "freeze" stuff: def counter(num): num = mutable(num) def inc(): num += 1 return num return inc (what is this thread doing on python-dev, btw? shouldn't it be over at the 3000 list, so I can enjoy my vacation without being drawn into yet another endless discussion thread ;-) </F>
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