> 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 _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com