numeric emulation and __pos__
samwyse
samwyse at gmail.com
Wed Jul 9 11:03:39 EDT 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
mailing list