Steven Bethard a écrit :

> The advantage of a functional form over a method shows up when you write
> a function that works on a variety of different types. Below are
> implementations of "list()", "sorted()" and "join()" that work on any
> iterable and only need to be defined once::
>
> [... skipped ...]
>
> Now, by providing these as functions, I only have to write them once,
> and they work on *any* iterable, including some container object that
> you invent tomorrow.

Yep. Rubyphiles would probably define these 3 methods in a "module"
Iterable and "mix" it in their brand new container classes.
These classes then automatically have list, sorted and join *as
methods*.

Guess you could use this kind of trick in Python if you can live with
heavy *and* implicit surgery of the inheritance chain ;)

Cheers,

SB

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to