#205: Monkey Patching
In last week's post we overwrote a method in the SSL module to use Feedparser with self-signed certificates. Today we take a closer look at the so called "monkey patching" and how it works under the hood.
In last week's post we overwrote a method in the SSL module to use Feedparser with self-signed certificates. Today we take a closer look at the so called "monkey patching" and how it works under the hood.
Python is usually a straightforward language without surprises. However, when you use the round() function you may run into some strange behaviour. Let us have a look at the specialities of round() and what is going on.
A few weeks back we were running a data preparation script that took a long time to complete. The main part of the work should not take that much time, but somehow that script was sloooow. I expected that the print() statement for each record would have an impact on performance, but I had no indication of the magnitude. Is it significant? Or is it neglectable? Let us find out how big the impact can be.
With the basics of date and time covered, we can look at how the dateutil module can help us with relative dates.
After a deeper look at date last week, we explore in this post the datetime and time objects of Python.
I waited a long time to address date and time because that topic has the potential to get complicated quickly. In a side project I needed some date arithmetic and that is a good opportunity to look at date and time in Python.
I needed to return multiple values from a function. While Python allows that with tuples, it is a lot of magic involved and the meaning in the order of values in the tuple is nowhere written down. Is there a better way to create a data transfer object without much effort? Let's find out.
While Python works great on Linux, Windows and Mac, there are tiny differences that may have big impacts on your code. I found this out the annoying way with a crashing application.
When you write scripts you often need to ask the user for an input. Let's look how we can do that in Python.
While working through a Pluralsight course I noticed a strange looking command that seams to make no sense: '-' * 100. As it turns out, we can multiply strings in Python and this provides some nice amenities for our cli applications.