Digital Education Resources - Vanderbilt Libraries Digital Lab

Note: this is an addendum lesson to a beginner’s introduction to Python. For the whole schedule, see the Vanderbilt Python Working Group homepage

prevous lesson on data from the Internet

How to Hack (a.k.a. practical problem solving)

The primary goal of these lessons has been to give you the skills necessary to solve practical problems using Python (as opposed to teaching you to be a Python developer). Since there is a virtually limitless number of possible problems, there is no way to provide a simple method for attacking them. However, there are some strategies that you can use to help you solve problems in an efficient way.

Google searches

As with most other computer users in the 2010’s, my first inclination when faced with a technical problem is to conduct a Google search. However, I’ve had varying levels of success depending on how I frame the queries.

One tip is to begin the query with “Python 3” (e.g. “Python 3 use API”). This helps screen out search results for languages other than Python and results that are based on Python 2. If the problem you are trying to solve involves an error, copy and paste the exact error message into the search bar. About 90% of the time, someone else will have had the same problem as you and the solution often will be clear.

You will commonly get a variety of kinds of results that may include blog posts, Stack Overflow questions and answers, YouTube videos, reference materials, and courses and tutorials. You can usually tell from the results titles how useful the results might be. I generall skip over the first “sponsored” search results since someone paid for them to be there, not because they are most helpful.

If you can find a good blog post where the writer is talking about solving your exact problem, that is usually the most helpful because a good post will often outline the issues and also provide code examples. Stack Overflow questions/answers can also be very helpful IF the problem is exactly the same as yours. Often the Stack Overflow question from the Google search result is somewhat different, but listed under the question are related questions and you can often find another question that is nearly identical to the problem you are trying to solve. The other issue with Stack Overflow is that the answers may be over your head if you are a Python beginner. For example, sometimes answers will involve complex object-oriented approaches. But other answers (or other questions’ answers) may provide a different code example that is less elegant, but easier to understand. So don’t give up!

I generally do not like YouTube videos because they take to long to assess whether they will actually be helpful or not.

Authoratative websites and reference materials

An obvious source of information is an authoritative website (for example the official Python documentation at https://docs.python.org/3/). The answer that you want is almost always there. However, because reference materials tend to be comprehensive, there is also information about many other things that are NOT the problem you are trying to solve. So it may take more time to find what you want than just finding a blog post or Stack Overflow question. Nevertheless, the official documentation is often helpful if you want to know things like all of the possible parameters and settings associated with a certain function.

In the case of packages, the package developer will often have instructions specific to the package at either GitHub or at readthedocs.org . These instructions range from extremely helpful and clear (with examples) to terse and obtuse. So it’s worth giving them a look and then deciding whether it’s worth your time to plow through them.

In some cases, your question may involve some kind of standard. Usually standards documents are very technical and dense, so they usually aren’t the best place to look for help. However, they are sometimes accompanied by a companion “primer” document with examples and simplified explanations. Those are usually really helpful.

Resorting to lessons

Depending on your learning style, you might opt for trying to find a tutorial or lesson that will help you systematically learn about the topic you are trying to hack. I am usually too impatient for lessons, but if you are feeling less confident, they might be right for you. I find W3School-style lessons (e.g. https://www.w3schools.com/python/) very helpful because they are usuall broken down into small chuncks that are focused on particular topics, usually provide easy-to understand examples, and sometimes have a “TryIt” editor that will allow you to actually run and modify the sample code. This can be really helpful if you are trying to understand the basic concepts that underly your problem.

There are also good YouTube lessons out there, but they require a greater time investment to check out.

I will also confess to actually having paper books for reference. I am often too impatient to look things up in them when Googling is an option, but sometimes books are the best solution, especially when you need a sequential explanation from simpler to more complex aspects of a problem. I am partial to books in the O’Reilly series because they often oriented towards beginners and are not thick reference books that contain so much information that it’s difficult to find what you want. Of course, you have to pay for them…

Finally, I should mention that there are good online courses that you can pay to take. I generally do not want to spend the time or money on them, but if you feel that you need a strong background in an entire area of programming, they might be an option for you. However, they may be geared towards people trying to upskill to a coding career, and might be more comprehensive than is necessary for someone who simply wants to use Python to solve a particular problem.


Revised 2019-04-18

Questions? Contact us

License: CC BY 4.0.
Credit: "Vanderbilt Libraries Digital Lab - www.library.vanderbilt.edu"