[Python-Dev] Arbitrary attributes on funcs and methods

David Ascher DavidA@ActiveState.com
Wed, 12 Apr 2000 15:51:36 -0700


Gordon McMillan:

> Jeremy Hylton wrote:

> > It prevents confusion and errors
> > that might result from unprincipled use of function attributes.
>
> While I'm sure I will be properly shocked and horrified when
> you come up with an example, in my naivety, I can't imagine
> what it will look like ;-).

I'm w/ Gordon & Barry on this one.  I've wanted method and function
attributes in the past and had to rely on building completely new classes w/
__call__ methods just to 'fake it'.  There's a performance cost to having to
do that, but most importantly there's a big increase in code complexity,
readability, maintanability, yaddability, etc.

I'm surprised that Jeremy sees it as such a problem area -- if I wanted to
play around with static typing, having a version of Python which let me
store method metadata cleanly would make me jump with joy.

FWIW, I'm perfectly willing to live in a world where 'unprincipled use of
method and function attributes' means that my code can't get optimized, just
like I don't expect my code which modifies __class__ to get optimized (as
long as someone defines what those principles are!).

--david