python: __doc__ doc trings is displayed as none
I coded a relatively simple script using python and also wrote doc strings for all the methods as follow:
def processData(rawData):
"""Pro开发者_StackOverflow社区ccessing raw data from weather station using Regex to get final sensor readings.
Args:
rawData: A string contains all the sensor readings. This string will be processed
using regex to remove garbage.
Returns:
finalList: A list of final sensor readings."""
However, when I tried to print the doc strings via interpreter the doc strings is printed out as "None"
>>> import ws100_weather_data as weather
>>> print weather.__doc__
None
But help(weather) display all the doc strings as well as other information. So am I doing anything wrong here? If I am, what is the right way to access doc strings?
Thank you.
There are different doc strings for different objects. The docstring for your function would be processData.__doc__
, for the module it is weather.__doc__
, which you didn't define. Define that as a bare string (unassigned) in the global scope at the top of the file.
You are showing us the doc string of one method. Presumably you do not have a doc string for the class.
精彩评论