Yet Another Python Tutorial.
The 2 hours part might be a bit optimistic, the idea was to have 12 lessons that would take approximately 10 minutes each, but, including the exercises, they all turned out to be maybe 2 hours each instead.
One could argue that the name of this tutorial would therefore need to be changed, but the content is still very introductory, so it is still applicable to some extent.
Python is a very popular programming language. It is used for a lot of different use cases from complicated applications such as AI or web browsers, to web application frameworks. But it is also considered (a bit arbitrarily) one of the easiest languages to learn and use, and this means it is also extensively used for scripting.
Python is an interpreted language, like most of the languages used for scripting. Whilst not known for high performance, in 99% of the use cases this limitation is not visible.
Beyond being easy to learn, and thanks to its vast popularity, one of the biggest advantages of Python is its community. This comprises of a large wealth of guides, tutorials and examples, but also libraries that help with all sort of different tasks, including making various API calls.
The sum of all these traits makes Python the perfect candidate for a tutorial like this. To guide the reader through the process of learning, we being with a foundation, and then explore some more advanced topics with Python.
This tutorial is designed to be self-paced. Anyone with a Unix/Linux/Mac environment should be able to do these exercises. We have also provided plenty of real-life examples for you to try out along the way.
Python, as a language, does not have a "Standards Committee" like C or C++ for example, so it is released in versions that bring different changes that might make one version incompatible with another.
Python version 2 has been around for a very long time, but it has been recently declared deprecated, so most of the Python distributions have now switched to python 3, and in particular versions > 3.5.
A lot of older code is still Python 2 specific, and migrating to Python 3 is not automatic.
For this reason this course will assume that you have a set-up with a version of Python above 3.5.
For most of the exercises, the version should not matter anyway.
It is recommended that you take the following lessons in order as they start with the simpler introductions and progress to more challenging examples.
- Lesson 1 - First Steps
- Lesson 2 - Your First Script
- Lesson 3 - Flow Control
- Lesson 4 - Predefined Types
- Lesson 5 - Functions and Comprehensions
- Lesson 6 - Classes and Objects
- Lesson 7 - Modules
- Lesson 8 - Reading and Writing Files
- Lesson 9 - Exceptions and Contexts
- Lesson 10 - Modules: Part 1: requests
- Lesson 10 - Modules: Part 2: json
- Lesson 10 - Modules: Part 3: lxml
- Lesson 10 - Modules: Part 4: re
- Lesson 10 - Modules: Part 5: argparse
- Lesson 10 - Modules: Part 6: logging
- Lesson 10 - Modules: Part 7: pyvmomi
- Lesson 11 - Pip and Virtualenv
The main source of information is the Python Documentation website, which will cover the answer to most of your questions regarding Python. In particular, check the Reference
The documentation is very useful, but at times it helps to understand specifically how a certain component needs to be used, and for that, most of the times stackoverflow is the best source of help.