> the block defined by the "on" statement first must starts looking at > the object's namespace. If no symbol was defined inside a, then it > follows the traditional LEGB name resolution. > > Assignament must work on the object's namespace, of course: This probably belongs to python-ideas or some such, but I don't think this approach can work. People will want to assign to local variables in an "ob" block, and then be surprised that the assignment actually modified their object: def f(L): total = 0 for h in L: on h: more code accessing h's attributes if x: # reads h.x total = total+1 return total People will be surprised that total is always 0 (and that some objects have an attribute total with a value of 1). Likewise on x: for e in L: counts[e] += 1 # modifies x.counts People will be surprised that x also grows an attribute e, as the for loop involves an assignment, which you say goes to the object's namespace, of course. Regards, Martin
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