3

I know that if you want to read documentation on functions it would look something like this:

print(function_name.__doc__)

or something like this:

print(help(function_name)

is there any possible way to find documentation on methods? Because when I tried to find information on .upper() or .lower() it would not simply work. I hope i'm not mixing terminology here.. and it's really called a method.

print(upper.__doc__) # print(help(lower)

dose not work .... and it's fine, these methods are very simple to understand... but what if we start using something like regex where there are many methods that look seemingly the same...but actually not.

example: re.findall() or re.search()

I would like to know what re(regex) module does or what findall or search method does... is there a possible way to do this without leaving your IDE?

I am extremely sorry, I'm very new to the language but I would love to get better without relying on "howto" videos or articles and finding out how to pull out documentation in different instances is very important for that matter.

2
  • 2
    upper is a method of str, so probably calling help(str.upper) will work. If not, you can call help on the class: help(str) Commented Sep 15, 2019 at 7:48
  • Thank you very much for your reply! yes, indeed help(str) showed documentation for .upper and .lower but is there possible way to pull information for only them instead of an entire set of methods? p.s is it possible to call documentation for modules? example is regex : import re Commented Sep 15, 2019 at 7:59

1 Answer 1

3

upper or lower are methods that act on string type. try this:
print(help("".upper)) or
print("".upper.__doc__) or
print(str.upper.__doc__)

Another example: print (append.__doc__) gives you an error.

but this works:
print(list.append.__doc__)

If you want to read the documentation on methods that are not builtin, just import the module and look for doc on that method. For instance.

import re
print(re.findall.__doc__)

Package information can be obtained using doc as well.

print(re.__doc__)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.