Python’s Self Type: How to Annotate Methods That Return self
Have you ever found yourself lost in a big repository of Python code, struggling to keep track of the intended types of variables? Without the proper use of type hints and annotations, uncovering variable types can become a tedious and time-consuming task. Perhaps you’re an avid user of type hints but aren’t sure how to annotate methods that return self or other instances of the class itself. That’s the issue that you’ll tackle in this tutorial. First, though, you’ll need […]
Read moreRecursion in Python
If you’re familiar with functions in Python, then you know that it’s quite common for one function to call another. In Python, it’s also possible for a function to call itself! A function that calls itself is said to be recursive, and the technique of employing a recursive function is called recursion. It may seem peculiar for a function to call itself, but many types of programming problems are best expressed recursively. When you bump up against such a problem, […]
Read morePython’s raise: Effectively Raising Exceptions in Your Code
In your Python journey, you’ll come across situations where you need to signal that something is going wrong in your code. For example, maybe a file doesn’t exist, a network or database connection fails, or your code gets invalid input. A common approach to tackle these issues is to raise an exception, notifying the user that an error has occurred. That’s what Python’s raise statement is for. Learning about the raise statement allows you to effectively handle errors and exceptional […]
Read moreHow to Make Engaging Programming Videos
Programming videos have become an increasingly popular medium for sharing knowledge and helping the fellow developers on your team. Especially when you’re working remotely, effective communication is vital, and screencasts have emerged as a powerful tool that meets this need. That’s why knowing how to make programming videos is a valuable skill, no matter where you are in your career. Even if you’ve never considered creating video content yourself, creating a screencast can be a great way to enhance written […]
Read more