Thoughts about Python

OKB (not okblacke) BrenBarn at aol.com
Tue Feb 24 13:16:25 EST 2004


Duncan Booth wrote:

> The advantage of min and max as builtins are that they work on any 
> sequence. In particular they work on iterators. Having functions
> that apply to an arbitrary sequence avoids a lot of potential code
> duplication. 

    	Wouldn't subclassing be an appropriate solution?  The most general 
sequence class/type could define a len method and the others would 
inherit it and override it if they have different length semantics.  In 
fact, Python already does this with the __len__ magic method.  Having a 
builtin function whose implementation is defined with a magically named 
method seems an awkward design.  Why not have just the method and do 
away with the function?

-- 
--OKB (not okblacke)
Brendan Barnwell
"Do not follow where the path may lead.  Go, instead, where there is
no path, and leave a trail."
	--author unknown



More information about the Python-list mailing list