"Phillip J. Eby" <[EMAIL PROTECTED]> wrote:
> At 09:24 AM 8/10/2006 -0700, Guido van Rossum wrote:
> >On 8/10/06, James Y Knight <[EMAIL PROTECTED]> 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.
> 
> 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.

Thankfully default dicts in Python 2.5 (they are in, right?) should
solve this particular nit of the language.  And by using default dicts
as an instance __dict__, you get similar behavior for attributes.


> 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.

I'm not sure that your characterization is entirely accurate.  I've
used and seen augmented assignments being used for many years now, and
this is the first time that I've seen anyone propose that it should work.


 - Josiah

_______________________________________________
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

Reply via email to