Steven D'Aprano <[EMAIL PROTECTED]> writes:
> def pmean(data):  # Paul Rubin's mean
>     """Returns the arithmetic mean of data, unless data is all 
>     ints, in which case returns the mean rounded to the nearest 
>     integer less than the arithmetic mean."""
>     s = sum(data)
>     if isinstance(s, int): return s//len(data)
>     else: return s/len(data)

Scheme and Common Lisp do automatic conversion and they thought out
the semantics rather carefully, and I think both of them return
exact rationals in this situation (int/int division).  I agree
with you that using // as above is pretty weird and it may be
preferable to raise TypeError on any use of int/int (require
either an explicit conversion, or use of //).
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to