is it "legal" to pace the module's doc string after some imports?

S

Stef Mientki

hello,

I wonder if it's "legal" to pace the module's doc string after some
imports ?

I mean something like this:

from language_support import _
__doc__ = _(0, """
some documentation
"""

thanks,
Stef Mientki
 
S

Steven D'Aprano

hello,

I wonder if it's "legal" to pace the module's doc string after some
imports ?

I mean something like this:

from language_support import _
__doc__ = _(0, """
some documentation
"""


Doc strings are normal objects like anything else, so the above should
work fine.

The only "magic" that happens with doc strings is that if you have a bare
string immediately after a class, method or function definition, or at
the top of the module, it gets picked up by the compiler and assigned to
__doc__. You can do anything you like to it.


You might even do this:

# top of module
"""This is some
documentation
blah blah blah
"""

try:
from language_support import _
__doc__ = _(0, __doc__)
except ImportError:
pass


and it should just work.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top