Range Operation pre-PEP

Terry Reedy reedy37 at home.com
Fri May 11 16:42:11 EDT 2001


> I can't think of a single function in the standard library which takes an
> unbounded number of heterogenous arguments.  I can think of several which
> take an unbounded number of homogeneous arguments.  'min' and 'max' for
> example.

Only if you define away heterogeneity by redefining 'homogeneous' as
meaning
'sensibly included together for processing by this particular function'.

>>> class num:
...   # simple minded example standing in for anything comparable to
builtin types
...   def __init__(self,val):
...     self.value = val
...   def __cmp__(self,other):
...     return cmp(self.value, other)
...
>>> min(1, 2L, 3.3, num(4))
1

For many (most?) languages, the above sequence of arguments is considered
heterogenous and is illegal as a standalone list or array.








More information about the Python-list mailing list