Python dot-equals (syntax proposal)

T

Terry Reedy

* Terry Reedy:
* Alf P. Steinbach:
and sometimes
they rebind the original target to the same object.

At the Python level that seems to be an undetectable null-operation.

If you try t=(1,2,3); t[1]+=3, if very much matters that a rebind occurs.
Testing:

t = ([], [], [])
t ([], [], [])
t[0] += ["blah"]
Traceback (most recent call last):
File said:
t (['blah'], [], [])
_
</test>

Yep, it matters.

So one should instead write t[0].extend('blah') to the same effect, but
without the exception raising assignment attempt, when that is what one
really means ;-).

Terry Jan Reedy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,149
Latest member
Vinay Kumar Nevatia0
Top