If you have stuck with Python up to this point, congratulations! You have learned the basics of Python scripting. Everything you have learned up to now has been an exercise to get you familiar with the syntax of Python as well as a few basic principles of programming and computer science. I mentioned when we introduced functions that there are a few things that are common to all programming languages. There are only a few more concepts common to many programming languages that we have not yet covered in Python. However, you now know enough to understand the majority of the language.
For this lesson, do the following steps:
Go to a website that hosts open source code such as PyPI. (GitHub also hosts Python code but it can be harder to find there.)
Search the website for Python code you can read.
You can usually find the source code linked with the “Homepage” link for any project.
Read one or two scripts from a project and see if you can figure out what the scripts are doing and how they are doing them.
As you work, take notes on things you notice about the code. How can you apply what you see in other’s code to your own code?
Like all of these lessons, what you put in to this exercise is what you will get out of it. If you put forth the effort and really try to understand the code you will gain some valuable insight into how real code is written.