Author: | Stephen J. Turnbull |
---|---|
Organization: | Faculty of Engineering, Information, and Systems at the University of Tsukuba |
Contact: | Stephen J. Turnbull <turnbull@sk.tsukuba.ac.jp> |
Date: | December 15, 2020 |
Copyright: | 2020, Stephen J. Turnbull |
Topic: | document |
What is "-fu"? The etymology is quite complicated and NSFW, but the word "foo" is used by many in software development to mean "stuff", and in this case "the right stuff". That is, "help-fu" is how you get good help. If "one's help-fu is weak" that means the person isn't good at getting help from the system. Probably the most common usage is "Google-fu".
Most modern interactive software systems provide some sort of help function. It's very useful to be good at using them, because they are frequently far more accurate than Google at finding the information you need.
Some this page provides concrete suggestions for finding information via software help functions. But also be aware that there is a knack to getting the most from help, and that can be described in words to some extent. However, the knack is something that you need to experience to understand, and you need to practice to fully take advantage.
Today I want to introduce Python, and the general scheme of using help. In the future I will do Jupyter/iPython, R, and Excel.
The help() function. In iPython/Juypter, R, and Maxima, you can also use '?'. Use is obvious. Most Python objects have a docstring, just ask for help(x) for an object named 'x'. Yes, the parentheses are required.
The dir() function. Tells you what an object can do, extremely briefly. It gives the names of the methods and data attributes that are available. Sometimes that is all that you need! dir() and help() require the exact name of an object.
The apropos function will search for keywords in the documentation for all the functions of Python, and return a list of those that discuss those keywords. Python itself doesn't have apropos. I think Jupyter/iPython does, and R and Maxima do. They call it ??.
For example, in R ordinary least squares is implemented in a module for linear models, by the abbreviated name lm. Most economists and business scientists wouldn't think to look there. How would you find it? By using apropos on the search term "ordinary least squares".
Like most software, Python has its own site https://www.python.org/, which provides general information. It also has a site especially for documentation, https://docs.python.org/.
For newcomers, the Tutorial is a useful introduction to Python, although it may seem quite dense, even difficult, for someone who is not experienced in programming. The Library Reference is worth becoming familiar with, because the main Python distribution includes a huge amount of functionality, including a simple descriptive statistics module:
% python3.8 -c 'import statistics as s; print(s.pstdev([1,2,3]))' 0.816496580927726
Because most of Python's functionality is in functions and classes, you probably won't need the Language Reference. For example, basic functionality like len(), print(), and help() are nowhere to be found in the Language Reference. Instead, they're in the Builtin Functions section of the Library Reference.
Knowing this kind of thing (where to look) is part of help-fu. Unfortunately, it's different for every project. I like the way Python organizes its documentation, but it's certainly not the only way.
Python has many individual 3rd party modules available from the Python Package Index (PyPI), https://pypi.python.org/. For example, webscraping, Twitter API, etc. You can search by keyword. Most projects have a page that documents their usage and features.
For statistical analysis, there are three huge projects for Python. Each has its own docs. site.
Because these are packages for Python, the dir() and help() functions are very useful to refresh your memory at the keyboard once you have a little bit of experience with them. Just like Python's own functionality.
There's a knack to Google, too. First of all, the search terms matter in subtle ways. When I compared "R least-squares" and "R documentation least-squares", I found that the former gave a lot of tutorials and simple examples that happen to use R but could have used Python or a commercial statistics package. But the latter than produced documentation on features of R and the details of specific R packages and commands that you use for least-squares regression, and the options of those commands that are rarely discussed in detail in the tutorial or example kind of pages.
Try adding search terms that express the kind of result you want, as well new terms that are more precise than the original terms. Substitute synonyms. Google is pretty good at picking up synonyms. But it often will change the precedence of results, and one may give much better "top results" than another.
Second, the general Google search and the Google Scholar search are both very useful in academic research. But remember that they give different kinds of results. Not only are they formatted differently and contain different information, but they also search different databases. You're not going to find blogs and newspaper articles via Scholar, but they can be useful. Academic blogs and "journal of record" newspapers frequently contain useful citations, and the content is frequently useful to understand potential policy applications or to provide background and motivation for your research.