Re: semantics of the |= operator

2008-08-24 Thread akva
thanks everybody. -- http://mail.python.org/mailman/listinfo/python-list

Re: semantics of the |= operator

2008-08-22 Thread Peter Pearson
On Fri, 22 Aug 2008 00:35:31 -0700 (PDT), akva <[EMAIL PROTECTED]> wrote: > > well, frankly I expected a |= b to mean exactly the same as a = a | b > regardless of the object type. So did I. I'm glad your post called this to my attention; I recently told my kid exactly that wrong thing. -- To

Re: semantics of the |= operator

2008-08-22 Thread Fredrik Lundh
akva wrote: could you please refer me a link where this is specified? I couldn't find it in python documentation http://docs.python.org/ref/augassign.html "An augmented assignment expression like x += 1 can be rewritten as x = x + 1 to achieve a similar, but not exactly equal effect. In the

Re: semantics of the |= operator

2008-08-22 Thread akva
thanks all, >Yes. That's the exact purpose of the in-place operators when they deal with >mutable objects. What else did you expect? well, frankly I expected a |= b to mean exactly the same as a = a | b regardless of the object type. > The manual explicitly specifies that mutable objects may imp

Re: semantics of the |= operator

2008-08-21 Thread Terry Reedy
akva wrote: Hi All, what's the exact semantics of the |= operator in python? It seems that a |= d is not always equivalent to a = a | d The manual explicitly specifies that mutable objects may implement the operation part of operation-assignments by updating in place -- so that

Re: semantics of the |= operator

2008-08-21 Thread Diez B. Roggisch
akva wrote: > Hi All, > > what's the exact semantics of the |= operator in python? > It seems that a |= d is not always equivalent to a = a | d > > For example let's consider the following code: > > def foo(s): >s = s | set([10]) > > def ba

semantics of the |= operator

2008-08-21 Thread akva
Hi All, what's the exact semantics of the |= operator in python? It seems that a |= d is not always equivalent to a = a | d For example let's consider the following code: def foo(s): s = s | set([10]) def bar(s): s |= set([10]) s = set([1,2]) foo(s) print s # prints set([1,