473,387 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

special operator =+

Hi,

Does anyone know the operator "=+"?
If you do, what special method is related to this operator?
Is it the __iadd__ method, but I think this is related to "+=" operator.

Thanks,
Kenny
Dec 15 '05 #1
5 1352
kenny Nguyen>Does anyone know the operator "=+"?

It isn't an operator, it's equivalent to = (assignment) only.

Bye,
bearophile

Dec 15 '05 #2
be************@lycos.com wrote:
kenny Nguyen>Does anyone know the operator "=+"?

It isn't an operator, it's equivalent to = (assignment) only.


Though actually it would try to call the __pos__ method on the object
prior to binding it to the name on the left side. (Much as - would call
the __neg__ method if it existed.) :-)

-Peter

Dec 16 '05 #3
Peter Hansen wrote:
be************@lycos.com wrote:
kenny Nguyen>Does anyone know the operator "=+"?

It isn't an operator, it's equivalent to = (assignment) only.

Though actually it would try to call the __pos__ method on the object
prior to binding it to the name on the left side. (Much as - would call
the __neg__ method if it existed.) :-)

Technically one shouldn't really say "it", since the sequence can only
occur in an assignment or a keyword argument specification, and in all
cases it's actually two symbols, an "=" followed by a unary "+" operator.

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/

Dec 16 '05 #4
On Thu, 15 Dec 2005 15:02:43 -0800, bearophileHUGS wrote:
kenny Nguyen>Does anyone know the operator "=+"?

It isn't an operator, it's equivalent to = (assignment) only.


No it is not.

py> x = []
py> x =+ [1]
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: bad operand type for unary +

It is equivalent to assignment followed by a unary plus.
--
Steven.

Dec 16 '05 #5
Steve Holden wrote:
Peter Hansen wrote:
be************@lycos.com wrote:
kenny Nguyen>Does anyone know the operator "=+"?
It isn't an operator, it's equivalent to = (assignment) only.


Though actually it would try to call the __pos__ method on the object
prior to binding it to the name on the left side. (Much as - would call
the __neg__ method if it existed.) :-)


Technically one shouldn't really say "it", since the sequence can only
occur in an assignment or a keyword argument specification, and in all
cases it's actually two symbols, an "=" followed by a unary "+" operator.


I think it's okay if the "it" in question is the Python interpreter, as
"it" is the thing that would be calling __pos__(). On the other hand,
trying to sort out all the definitions of "it" in the above is probably
at this point a rather Clintonesque endeavour.

-Peter

Dec 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

24
by: Steven Bethard | last post by:
I think one of the biggest reasons we're having such problems coming to any agreement on decorator syntax is that each proposal makes a number of syntax decisions, not just one. For decorators, I...
3
by: jamesthiele.usenet | last post by:
I was starting to write a dictionary to map operator strings to their equivalent special methods such as: { '+' : 'add', '&' : 'and_' } The idea is to build a simple interactive calculator. ...
3
by: klaas | last post by:
the following code gives rise to the beneath error message, only when a matrix object is instantiated as matrix<bool>, not with matrix<float>: /*returns a reference to the object at position...
2
by: Bobo | last post by:
Hello, all. I have just wrote the following little class, and I'd like you to give me your opinion about it. I compiles with VC6 but I'm not sure if it is totally right. I'm trying to explain...
4
by: J.J.García | last post by:
Hi, I have defined an static operator in a class, and when I try to use it inside of the class, my compiler --Visual C++ 7.1-- complains saying that there not exist an operator that suits the...
2
by: typingcat | last post by:
Say I have a table in a MySQL server ID USERNAME COUNT 0 JOHN 2 1 JANE 3 2 HOMER 3 3 MOE 2 If I want to increase Homer's count by 1, The plain way would be;...
3
by: infinity | last post by:
Hi all, Is constructor a special member function? But I don't think it is either a member function or even a special member function although it has the syntax of a function. I think it confused...
3
KevinADC
by: KevinADC | last post by:
Purpose The purpose of this article is to discuss the difference between characters inside a character class and outside a character class and some special characters inside a character class....
5
by: Chris Thomasson | last post by:
Does this program produce any undefined-behavior: http://pastebin.com/m5eb3c81a ?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.