Method / Functions - What are the differences?

John Posner jjposner at optimum.net
Thu Mar 18 17:48:35 CET 2010


On 3/10/2010 8:37 PM, Gabriel Genellina wrote:
> En Wed, 10 Mar 2010 11:45:38 -0300, John Posner <jjposner at optimum.net>
> escribió:
>
>> As I promised/threatened, here's the *start* of a write-up on
>> properties, aimed at non-advanced Python programmers:
>>
>> http://www.jjposner.net/media/python-properties-0310.pdf
>
> I'd use 'function' instead of 'procedure', as this last word is very
> uncommon in Python literature (also, "the procedure's return value..." may
> look very strange to some people).

I was trying to avoid the function-vs-method swamp, and so I used 
"procedure". I agree that it was an unfortunate strategy. In a rewrite, 
I'm using "function" for the most part

>
> I'm unsure if one should make a distinction 'storage attribute' vs.
> 'method attribute', or even if it makes things actually more clear.

Agreed -- I was trying too hard to be helpful, and introduced 
unnecessary terminology.

> ... I
> think you could present the motivating idea first ("I want to execute some
> code when accessing an attribute") and only later talk about properties

That was my intention. I hope it comes across more clearly in the rewrite.

> and descriptors (as written, the reader still doesn't know how to define a
> simple property and you've already talked about deleting attributes...)

That doesn't bother me. It's OK to describe capabilities -- but not give 
how-to's -- in an overview section.



And Edward Cherlin wrote:

> I find that it will explain things to those who already understand
> most of the concepts. However, I felt as though I were being led
> through a maze without knowing where we were headed.

   ...

> Who is your expected audience?

I was headed toward having the reader *really* understand the @property 
decorator. And I was intending that reader to be a non-advanced Python 
user -- say, at the CS 101 level. I'm now convinced that such a goal was 
"a bridge too far". It has a lot moving parts, including a prerequisite 
that is a major topic in itself -- the descriptor protocol. That puts 
the goal way beyond reach.




There's another draft at:

   http://www.jjposner.net/media/python-properties-0318.pdf


Many thanks for your comments,
John



More information about the Python-list mailing list