Uses for unary + (was Re: New Python language abuse: ++x with bytecodehacks)
Jeff Epler
jepler at inetnebr.com
Thu Jul 8 22:02:43 EDT 1999
On Thu, 8 Jul 1999 15:35:05 GMT, Christian Tismer
<tismer at appliedbiometrics.com> wrote:
>p.s.: I wondered why Guido didn't optimize a double
>unary positive. But he can't, since he has no idea what
>this operator does.
Because nobody has a reason to type it?
I also overloaded the meaning of unary + when I was working with classes
that acted like numeric types. ref[:] is a nice way to do a shallow copy
of sequence types, and "+ref" is a nice way to denote a shallow copy of a
numeric type. (You just have to write the method __pos__ to do so)
Jeff
PS Too bad that dictionaries don't support dict[:] to make a copy too!
--
\/ http://incolor.inetnebr.com/jepler/ Jeff Epler jepler at inetnebr.com
"But I don't like Spam!!!!"
More information about the Python-list
mailing list