Functions vs OOP

Terry Reedy tjreedy at udel.edu
Sat Sep 3 15:15:28 EDT 2011


On 9/3/2011 12:25 PM, Steven D'Aprano wrote:
> William Gill wrote:
>
>> During some recent research, and re-familiarization with Python, I came
>> across documentation

Ours, or someone else's?

>> that suggests that programming using functions, and
>> programming using objects were somehow opposing techniques.
>>
>> It seems to me that they are complimentary.  It makes sense to create
>> objects and have some functions that take those objects as arguments.
>
> Python is a mixed paradigm language, with object, functional and imperative
> paradigms.
>
>> Are they suggesting that any function that takes an object as an
>> argument should always be a method of that object?

Or of the class of the object.

> Yes.
> http://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html

Since in Python, everything is an object, that would mean that every 
function has to be a method, which would mean creating classes just to 
have a class to attach functions to. How awful. (Oh, right, I believe I 
just described Java.)

>> Am I missing something, or am I taking things too literally?
>
> No, it is the OO purists who are missing something.

Yes, Python.

-- 
Terry Jan Reedy




More information about the Python-list mailing list