Вопрос

I coded a relatively simple script using python and also wrote doc strings for all the methods as follow:

def processData(rawData):
    """Proccessing 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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top