numeric emulation and __pos__
samwyse at gmail.com
Wed Jul 9 17:03:39 CEST 2008
On Jul 8, 12:34 pm, Ethan Furman <et... at stoneleaf.us> wrote:
> Anybody have an example of when the unary + actually does something?
> Besides the below Decimal example. I'm curious under what circumstances
> it would be useful for more than just completeness (although
> completeness for it's own sake is important, IMO).
Well, as in Decimal, it would be a good operator to use for
canonization. Let's say you implement complex numbers as an angle and
radius. Then, unary plus could be used to normalize the angle to +/-
Pi and the radius to a positive number (by inverting the angle).
More information about the Python-list