String Methods Don't Change ID?

Brian Quinlan brian at sweetapp.com
Mon Jan 27 23:11:38 EST 2003


> Calling a method on a string SEEMS like it should modify the original,
> not create a new one, but I guess strings are 'special' all the way
> around.  

Strings are not any more special than numbers. When you write:

>>> (-5).__abs__()
5

I hope that you don't expect all of the -5s in the system to suddenly
become positive 5s :-)

Cheers,
Brian






More information about the Python-list mailing list