Decimals -> Fraction strings, my solution

Moshe Zadka moshez at math.huji.ac.il
Tue May 23 00:31:05 EDT 2000


On Thu, 18 May 2000, David C. Ullrich wrote:

> 	The reason the counter-quibble seems worth 
> mentioning is that the abs makes it much less generic: 
> Without the abs you can use the function for any 
> objects with a __mod__ method (assuming that a has 
> to eventually become false for some reason). For 
> example you can use it to find the gcd of two 
> polynomials a and b, if you give your polynomials 
> an appropriate __mod__. (I don't think there's any
> such thing as an appropriate __abs__ for polynomials...)

Hmmmm.....there should be an __representative__, which would take a unique
representative from the equivalence class of "self", where equivalence is 
defined

a ~ b <==> there exists i, i invertible, a*i = b

abs() does this for Z, normalize() does this for polynomials, etc.

new-__-protocols-a-dollar-ly y'rs, Z.
--
Moshe Zadka <moshez at math.huji.ac.il>
http://www.oreilly.com/news/prescod_0300.html
http://www.linux.org.il -- we put the penguin in .com





More information about the Python-list mailing list