Pergunta

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.

Foi útil?

Solução

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.

Outras dicas

You are showing us the doc string of one method. Presumably you do not have a doc string for the class.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top