>>>> If I have a script called main.py and document a function in it:
>>>>
>>>> def get_value(x):
>>>> """
>>>> Some text ...
>>>> :param x: Some value
>>>> :returns: Something useful
>>>> """
>>>>
>>>> What is the most basic way of showing those docstrings at the
>>>> Python prompt?
>>>
>>> Try:
>>>
>>> help(get_value)
>>>
>>> At the Python prompt. This uses the built in help facility:
>>>
>>> https://docs.python.org/2/library/functions.html#help
>>>
>>
>> I understand that 'help' works with modules that I have imported. But if
>> I've just written a script called main.py (which contains get_value()) I
>> don't think I can 'import' that. So how would I see the docstrings in
>> main.py?
>>
> Try it! you'll find it works fine
So main.py contains:
def get_field(value, start_bit, end_bit):
<snip>
and I see:
>>> import main
>>> help(get_field)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'get_field' is not defined
help(main) works ok but is rather verbose.
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor