Class Variable Access and Assignment

Bengt Richter bokr at oz.net
Fri Nov 4 22:28:21 EST 2005


On 04 Nov 2005 17:53:34 -0800, Paul Rubin <http://phr.cx@NOSPAM.invalid> wrote:

>bokr at oz.net (Bengt Richter) writes:
>> Hm, "the" fix? Why wouldn't e.g. treating augassign as shorthand for
>> a source transformation (i.e., asstgt <op>= expr becomes by simple
>> text substitution asstgt = asstgt <op> expr) be as good a fix? Then
>> we could discuss what
>
>Consider "a[f()] += 3".  You don't want to eval f() twice.

Well, if you accepted macro semantics IWT you _would_ want to ;-)

Hm, reminds me of typical adding of parens in macros to control precedence
in expressions ... so I tried
 >>> a = [0]
 >>> (a[0]) += 1
 SyntaxError: augmented assign to tuple literal or generator expression not possible

;-/

Regards,
Bengt Richter



More information about the Python-list mailing list