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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Stef Mientki

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

    hello,

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

    I mean something like this:

    from language_suppor t import _
    __doc__ = _(0, """
    some documentation
    """

    thanks,
    Stef Mientki

  • Steven D'Aprano

    #2
    Re: is it "legal&quo t; to pace the module's doc string after someimports ?

    On Sun, 26 Oct 2008 02:31:01 +0200, Stef Mientki wrote:
    hello,
    >
    I wonder if it's "legal" to pace the module's doc string after some
    imports ?
    >
    I mean something like this:
    >
    from language_suppor t 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_suppor t import _
    __doc__ = _(0, __doc__)
    except ImportError:
    pass


    and it should just work.


    --
    Steven

    Comment

    Working...