[Python-Dev] Arbitrary attributes on funcs and methods

Greg Stein gstein@lyra.org
Wed, 12 Apr 2000 12:33:18 -0700 (PDT)


On Wed, 12 Apr 2000, Jeremy Hylton wrote:
>...
> It would look really, really bad ;-).  I couldn't think of a good
> example, so I guess this is a FUD argument.  A rough sketch, though,
> would be a program that assigned attribute X to all functions that
> were to be used in a certain way.  If the assignment is a runtime
> operation, rather than a syntactic construct that defines a static
> attribute, it would be possible to accidentally assign attribute X to
> a function that was not intended to be used that way.  This connection
> between a group of functions and a particular behavior would depend
> entirely on some runtime magic with settable attributes.

This is a FUD argument also. I could just as easily mis-label a function
when using __doc__ strings, when using mappings in a class object, or
using some runtime structures to record the attribute.

Your "label" can be recorded in any number of ways. It can be made
incorrect in all of them. There is nothing intrinsic to function
attributes that makes them more prone to error.

Being able to place them into function attributes means that you have a
better *model* for how you record these values. Why place them into a
separate mapping if your intent is to enhance the semantics of a function?
If the semantics apply to a function, then bind it right there.

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/