+= overloading?
Roman Suzi
rnd at onego.ru
Sun Jun 17 01:31:14 EDT 2001
On Sat, 16 Jun 2001, Neil Macneale wrote:
>I am creating a colored stringbuffer class, and I want to append words to
>the buffer with the '+=' operator. Ex:
>
>>>>csb = CSB("INIT STRING")
>>>>csb += "Hello"
>>>>print csb
>INIT STRINGHello
>
>would be the desired effect. I can't seem to find anything in the lib
>docs about overloading that operator though. Am I looking in the wrong
>place? It is also important that a new object is NOT created every time
>the operator is used, because that would be a waste.
class CSB:
def __iadd__(self, x):
self._string += x
>Suggestions? Thanks for any tips!
>
>Neil Macneale
>
>--
>To reply to me via email, remove the '-devnull' from my address.
>
Sincerely yours, Roman Suzi
--
_/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/
_/ Sunday, June 17, 2001 _/ Powered by Linux RedHat 6.2 _/
_/ "Tis better to have loved a short than to never have loved a tall." _/
More information about the Python-list
mailing list