[Python-Dev] Arbitrary attributes on funcs and methods
Andrew Kuchling
akuchlin@mems-exchange.org
Wed, 12 Apr 2000 08:22:26 -0400 (EDT)
Vladimir Marangozov writes:
>Barry, I wonder what for...
In the two quoted examples, docstrings are used to store additional
info about a function. SPARK uses them to contain grammar rules and
the regular expressions for matching tokens. The object publisher in
Zope uses the presence of a docstring to indicate whether a function
or method is publicly accessible. As a third example, the optional
type info being thrashed over in the Types-SIG would be another
annotation for a function (though doing def f(): ... f.type = 'void'
would be really clunky.
>Once the puzzle would be solved, we'll discover that there would be only
>one additional little step towards inheritance for modules. How weird!
>Sounds like we're going to metaclass again...
No, that isn't why Barry is experimenting with this -- instead, it's
simply because annotating functions seems useful, but everyone uses
the docstring because it's the only option.
--amk