Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info> writes:

> LJ wrote:
>
> > def gt(l):
> >    a["1"] = a["1"] | set([l])
>
> The difference between this example and your second one:
>
> > def gt2(l):
> >    b=b+l
>
>
> is that the second is a "binding operation" and the first is not.

I disagree; they're both binding operations (and they both use the
binding operator ‘=’ to express this).

The difference between the two is: what reference is being bound?

* In the first example, the reference is ‘a["1"]’.

  That reference is re-bound to a different object; whatever object it
  was previously bound to is forgotten.

* In the second example, the reference is ‘b’.

  That reference is re-bound to a different object; whatever object it
  was previously bound to is forgotten.

So, both of them bind (or re-bind) a reference to an object. The only
difference between the operations is the parameters.

-- 
 \      “People always ask me, ‘Where were you when Kennedy was shot?’ |
  `\                        Well, I don't have an alibi.” —Emo Philips |
_o__)                                                                  |
Ben Finney

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to