Are routine objects guaranteed mutable & with dictionary?

Alf P. Steinbach alfps at start.no
Sat Dec 5 05:26:34 EST 2009


* Raymond Hettinger:
> On Dec 4, 2:03 am, "Alf P. Steinbach" <al... at start.no> wrote:
>> Is this guaranteed to work in Python 3.x?
>>
>>  >>> def foo(): pass
>> ...
>>  >>> foo.blah = 222
>>  >>> foo.blah
>> 222
> 
> Yes, function attributes are guaranteed to be writable:
> http://www.python.org/dev/peps/pep-0232/

Thanks to all, especially you and Terry.

To quote a suspected bot once rampaging the Microsoft groups, "my question has 
been answered!" :-)

Thread morphing:

Regarding my terminology, "routine" instead "function" that everybody except you 
remarked on, it is of course intentional. After all, my main language is C++. 
And nobody (well, very few) would accuse me of not knowing my C++. :-)

I use the term "routine" because I think the terminology influences what we can 
easily think of and what we therefore tend to use and/or discuss. In that 
respect I think people need to be educated to use more language independent, or 
Eiffel-like, or just historically original, terminology, because

   * "function" is misleading in itself (due to the hijacking of this term in
     mathematics), and

   * it gets worse when you can't reasonably talk about "co-functions" or
     "function-like functions". :-)

The devolution of terminology has been so severe that now even the Wikipedia 
article on this subject confounds the general concept of "routine" with the far 
more specialized term "sub-routine", which is just one kind of routine. It is of 
course OK with me that there is a default meaning, and that there are several 
different context dependendent meanings. I'm just mentioning this as an example 
that the terminology effectively constrains one's thinking, to the degree that 
even a moderately long encyclopedia article on the subject fails to mention or 
focus on the important aspects. Perhaps modern programmers should be forced to 
study Donald Knuth's TAOCP. Or something.


Cheers,

- Alf



More information about the Python-list mailing list