Toggle Menu Icon
Working with Python

Working with Python

Working with Python is a set of code examples to help someone get things done with Python. By someone, I mean myself. I end up reading and referencing these docs often.

Book

Downloadable PDF: Working-with-Python.pdf

I’ve compiled these posts into a downloadable PDF so you can take it with you. If you find Working with Python helpful, consider supporting it with a small donation. I put a lot of time and effort in putting this all together, pay what you think it is worth. 🙏

About the guide

The Python code examples can be pasted directly into the REPL, to support this I reverse the >>> that indicate an input line in the REPL, and switch it with the output line, which has no prefix.

In your terminal, the join list example would look like:

>>> a =[1, 2, 3]
>>> b = [4, 5, 6]
>>> a + b
[1, 2, 3, 4, 5, 6]

But if you try and copy and paste it makes it hard, especially for multiple lines. So I reverse them which makes it easier to copy-paste examples to test out. In the guide the example is shown as:

a = [1, 2, 3]
b = [4, 5, 6]
a + b
>>> [1, 2, 3, 4, 5, 6]

Additionally, the REPL will automatically display the return value or variable as shown above. So, I tend not to use print(), unless showing a specific example. It is not necessary to have print(a + b) or an even more verbose c = a + b and then another line to print(c).