469,917 Members | 1,848 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,917 developers. It's quick & easy.

+= append class operator

Hi All,

This is probably a FAQ, but is there an operator mapping for += for
classes? Or does a += b get converted to a = a + b? I would like to
make this operator faster for the BitVector class, but I don't see +=
in http://docs.python.org/lib/operator-map.html

I could always create an append method, but += is nice and concise.

Thanks,
-kurt

Apr 19 '06 #1
2 1120
sc*****@gmail.com wrote:
This is probably a FAQ, but is there an operator mapping for += for
classes?
obj.__iadd__(other)
Or does a += b get converted to a = a + b?
only if __iadd__ is not defined.
I would like to make this operator faster for the BitVector class, but
I don't see += in http://docs.python.org/lib/operator-map.html


that's documentation for the operator module.

special method names are described in the language reference:

http://docs.python.org/ref/specialnames.html
http://docs.python.org/ref/numeric-types.html

</F>

Apr 19 '06 #2
Awesome. Thanks!

-kurt

Apr 19 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

25 posts views Thread by Yves Glodt | last post: by
4 posts views Thread by Sandro Dentella | last post: by
26 posts views Thread by John Salerno | last post: by
14 posts views Thread by lovecreatesbea... | last post: by
3 posts views Thread by Hamilton Woods | last post: by
2 posts views Thread by jeremito | last post: by
42 posts views Thread by Armin | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.