[Python-ideas] Adding some standalone iterator/sequence functions as methods of the iterator objects

Steven D'Aprano steve at pearwood.info
Fri Aug 14 09:58:51 CEST 2009

On Fri, 14 Aug 2009 02:23:08 am Bill Janssen wrote:
> Interesting thread.
> Is Python procedural (function-oriented)?  My opinion is that it was,
> when it started out, but isn't really any more, 

Python has always been object-oriented. I don't have direct experience 
with the releases before version 1.5, but all data in Python were 
objects then, and they remain objects now.

Python has *also* always been procedural: Python supports a mix of OO 
and procedural programming very naturally. It would be difficult to 
write a non-trivial program using "pure" OO or "pure" procedural styles 

Python has also always supported (albeit weakly) a functional style. 
Although it doesn't make the guarantee of "no side-effects" that purely 
functional languages do, Python has provided functional tools like 
filter(), map() and reduce() since the 1.x series, and with more and 
more iterator-based code, Python is arguably becoming more functional 
rather than less.

> Unfortunately, it seems to me that Python currently makes mixins
> somewhat clumsy to use.  We could use a low-weight way of making a
> class which is a mix of three or four mixins, much as "lambda"
> provides a low-weight way of producing a small function.  Something
> like
>     a = class(Mixin1, Mixin2, Mixin3)()
>     a.mixin1_method_foo()
>     a.mixin3_method_bar()

What's wrong with



As far as I know, the caller shouldn't need to know or care where a 
inherits the method `foo` from, or even if it is inherited. On the rare 
occasion the caller does want to specify which base class' method to 
call, you can do it with:


Steven D'Aprano

More information about the Python-ideas mailing list