[Tutor] Basic question about docstrings
Steven D'Aprano
steve at pearwood.info
Thu Jul 30 19:09:37 CEST 2015
On Thu, Jul 30, 2015 at 04:28:33PM +0000, David Aldrich wrote:
> 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
Naturally. Name resolution works the same for help() as for anything
else.
If you say:
import math
then you need to refer to math.sin and math.cos, not sin or cos on their
own. The same applies to your main.get_field, whether you are using
help() or not.
--
Steve
More information about the Tutor
mailing list