Some more notes
jerf at jerf.org
Fri Oct 22 07:00:32 CEST 2004
On Thu, 21 Oct 2004 17:59:41 -0700, Cliff Wells wrote:
>> 7) There's something that I don't understand. I'm not a OOP purist
>> but finding functions like this beside normal methods seems odd to me:
>> len(s) length of s
>> min(s) smallest item of s
>> max(s) largest item of s
>> For uniformity they can be:
> I don't have a good answer for this.
See the current thread "Python and generic programming". Those are
probably best though of as generic algorithms that can work even when
"max" isn't implemented.
Python 2.3.4 (#1, Sep 28 2004, 20:15:25)
[GCC 3.3.3 20040412 (Gentoo Linux 3.3.3-r6, ssp-3.3.2-2, pie-8.7.6)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> def somenumbers():
... yield 1
... yield 5
... yield 2
"max" isn't a method in any sense of the term that I am aware of, so it
would be wrong to put it there. In some sense, then, this is *more* pure
OO than, say, Java's "Everything is a method of some object and to hell
with the consequences!" approach.
(It seems like the more mature I get as a programmer, the more Java
disgusts me. I'm beginning to have to stretch for reasons to like it at
all; one after another they keep falling down for me. But I digress...)
More information about the Python-list