At 09:24 AM 8/10/2006 -0700, Guido van Rossum wrote: >On 8/10/06, James Y Knight <foom at fuhm.net> wrote: > > It makes just as much sense as assigning to an array access, and the > > semantics would be pretty similar. > >No. Array references (x[i]) and attribute references (x.a) represent >"locations". Function calls represent values. This is no different >than the distinction between lvalues and rvalues in C. IIRC, in Lisp a function call can be an lvalue. OTOH, that's probably because in Lisp there isn't anything besides function calls. :) I'm having a hard time imagining a use case in Python, though, except to allow things like "somedict.setdefault(key,0) += 1". And I'm not sure that's an improvement, although there have certainly been times that I started to write that, and then grumbled and wrote "somedict[key] = somedict.setdefault(key,0) + 1" instead. Honestly, it might make more sense to get rid of augmented assignment in Py3K rather than to add this. It seems that the need for something like this springs primarily from the existence of augmented assignment.
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