5 Python Tricks You Should Know

How to supercharge your python beyond the basics with ease

Aaron S
The Startup

--

Python has such an amazing support network it can almost seem like there is too much to take in all at once. This is normal and should be recognised. It can be confusing for those starting out. You can find vast quantities of resources to grapple with the basics but then what ? Where do you go to keep improving?

Here, I list my top 5 useful snippets of code which I felt pushed my level up further and made my code better. You will start to see how you can implement these five things into your code.

1. List comprehensions

You may have heard of these before. A pattern of coding in python is so common that it warrants a modification. Any time you want to use a for loop to create a list. This is where list comprehensions can be useful.

They are readable and concise. They do take a bit of time to wrap your head around what is going on. Let's dive in and see if we can figure this out.

We know list comprehensions should be thought of when you want to create a list. A list comprehension begins with a set of square brackets. Let's get the syntax out of the way and we can show how the two are alike

list_comp = [expression for item in…

--

--

Aaron S
The Startup

Hello! My name is Aaron. Healthcare professional with an interest in python, technology, education and healthcare.I run coding-medic.com for python enthusiasts.