Get dosctring without import

Joan Miller peloko45 at gmail.com
Fri Feb 26 12:23:17 CET 2010


On 26 feb, 10:51, Ben Finney <ben+pyt... at benfinney.id.au> wrote:
> Joan Miller <pelok... at gmail.com> writes:
> > When a package is imported, it gets the dosctring to store it in
> > *__doc__*.
>
> Joan, in this message and numerous others you've been following the
> widespread convention of using asterisks ‘*’ to surround text you want
> to emphasise.
>
> Normally that's good, but in a programming-language context (or any
> other where asterisks have a separate established meaning), it's not a
> good idea. In many cases, asterisks signify “match any number of
> arbitrary characters at this position”, which gives a rather different
> meaning to what you're writing.
>
> You might be better off using quotes (like '__doc__' or ‘__doc__’), or
> the reStructuredText syntax for demarcating a special element, backticks
> (like `__doc__`). Even they need to be used with care, though, because
> they also have specific established meanings (except the typographical
> quotes, which is why I use them).
>
> I hope that helps.
>
> > Does that funcion is built in python? because I would want use it to
> > get the docstring without import a package
>
> Why is it you want to do this? Modules should not have unwanted side
> effects when imported; if you can't import the module without invoking
> those unwanted side effects, the module is poorly written.
>
> That's not to say that such poorly-written modules don't exist. What is
> the situation? Perhaps there's a better solution.
I use a function in 'setupy.py' to get automatically the description
from the package's docstring, but there is a problem when you import a
module that has to be built by cython (because it tries load a module
that doesn't exists).



More information about the Python-list mailing list