Thanks bearophile,

I prefer not to use docstrings for metadata.

1. Not interfering with the other accepted docstring uses may be
difficult (doctests, epydoc)

2. It's impractical for attributes generated by code:

@attr(reference_profile_stats=pstats.Stats("foo.profile"))
def foo():
  ...

Regards,
Ori.

[EMAIL PROTECTED] wrote:
> oripel:
>
> Maybe this is a silly suggestion, the docstring is already overloaded,
> but it may be used for this too:
>
> def foo():
>     """
>     ...
>     ...
>     @ATTR name="Xander"
>     @ATTR age=10
>     @ATTR hobby="knitting"
>     """
>     ...
>
> (Or somethins similar without the @). Later you can retrive the
> attributes from the docstring, for example using a verbose RE like:
> r"\s* @ATTR \s+ (\w*) \s* = \s* (.*)"
> And you use it to create a dict of attributes.
> The decorators you apply to foo() must keep its docstring too.
> 
> Bye,
> bearophile

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to