Reputation: 14656
Let's say I have a package omegaproject
I'm importing from a script test.py
:
test.py
omegaproject/
__init__.py
omega.py
Say that in __init__.py
I've put """Hello there"""
and nothing else.
Now, say that test.py
consists of:
import omegaproject
print(omegaproject.__doc__)
Shouldn't running test.py
cause Python to display 'Hello there'? Instead, it displays nothing.
In other words, where do I specify the docstring of a package?
Upvotes: 0
Views: 108
Reputation: 14656
Let's call this a "trick question" :)
As Martijn points out, in fact the docstring does appear as desired.
The problem was in this sequence of events:
__init__.py
empty. test.py
, which printed nothing.__init__.py
to have a docstring reading """Hello there"""
import omegaproject
followed by omegaproject.__doc__
But omegaproject had already been imported! So the second import did nothing, the docstring did not get updated, and so the docstring was still showing as blank.
Upvotes: 1