I just installed this library that scrapes twitter data: https://github.com/kennethreitz/twitter-scraper
I wanted to find out the library's functions and methods so I can start interacting with the library. I have looked around StackOverflow on this topic and tried the following:
pydoc twitter_scraper
help(twitter_scraper)
dir(twitter_scraper)
imported inspect and ran functions = inspect.getmembers(module, inspect.isfunction)
Of the four things I have tried, I have only gotten an output from the inspect option so far. I am also unsure (excluding inspect) whether these codes should go in the terminal or a scratch file.
Still quite new at this. Thank you so much for reading everybody!
Excellent question! There are a few options in trying to grok (fully understand) a new library. In your specific case, twitter-scraper, the only function is get-tweets()
and the entire library is under 80 lines long.
For the general case, in decreasing order of usefulness.
pydoc module_name
works when the module is installed. ``help(module_name)works in an interactive Python session after you have done an
import module_name. These both work from the "docstrings" or strategically placed comments in the source code. This is also what
module_name?` does in iPython.dir(module_name)
also requires an import. It lists all the entrypoints to the module, including lots of odd "dunder", or double underscore, you would not normally call or change.Also, you asked about what can be used within a script:
import os
print("Welcome, human.")
print("dir() is a function, returning a list.")
print("This has no output")
a_list = dir(os)
print("but this does", dir(os))
print("The help() command uses pydoc to print to stdout")
help(os)
print("This program is gratified to be of use.")