[Python-Dev] Arbitrary attributes on funcs and methods
Jeremy Hylton
jeremy@cnri.reston.va.us
Wed, 12 Apr 2000 12:37:20 -0400 (EDT)
>>>>> "BAW" == Barry A Warsaw <bwarsaw@cnri.reston.va.us> writes:
BAW> Functions and methods are first class objects, and they already
BAW> have attributes, some of which are writable. Why should
BAW> __doc__ be special? Just because it was the first such
BAW> attribute to have syntactic support for easily defining?
I don't have a principled argument about why doc strings should be
special, but I think that they should be. I think it's weird that you
can change __doc__ at runtime; I would prefer that it be constant.
BAW> Think about my proposal this way: it actually removes a
BAW> restriction.
I think this is really the crux of the matter! The proposal removes
a useful restriction.
The alternatives /F suggested seem clearer to me that sticking new
attributes on functions and methods. Three things I like about the
approach: It affords an opportunity to be very clear about how the
attributes are intended to be used. I suspect it would be easier to
describe with a static type system. It prevents confusion and errors
that might result from unprincipled use of function attributes.
Jeremy