numeric emulation and __pos__
samwyse
samwyse at gmail.com
Tue Jul 8 09:32:51 EDT 2008
On Jul 7, 6:12 pm, Ethan Furman <et... at stoneleaf.us> wrote:
> Greetings, List!
>
> I'm working on a numeric data type for measured values that will keep
> track of and limit results to the number of significant digits
> originally defined for the values in question.
>
> I am doing this primarily because I enjoy playing with numbers, and also
> to get some experience with unit testing.
>
> At this point I have the __init__ portion finished, and am starting on
> the various operator functions.
>
> Questions for the group:
>
> 1) Any reason to support the less common operators?
> i.e. <<, >>, &, ^, |
>
> 2) What, exactly, does .__pos__() do? An example would help, too.
1) Those make much less sense for non-integers. I'd say skip them.
2) It's an overridable no-op that implements the unary plus
operator. Unary plus returns its value unchanged, as does __pos__.
More information about the Python-list
mailing list