Home » Python (page 4)

Python

A Problem With Python’s Code Blocks

So, this post was going to be completely different. I was going to do a post on how you can restrict the creation and scoping of certain objects using Python’s with code blocks. Unfortunately, with doesn’t restrict scope. Take the following code sample: with someManager() as i: # do something with i print(i) This will, unfortunately, work and print whatever ...

Read More »

Default Implementations Using Delegation

Hey everyone! It’s my first post of the new year! Usually, I do a bunch of book reviews at the beginning of the year, and I will certainly do that in upcoming posts. Also, don’t worry that I may have given up on my video series; I haven’t. I’m simply being a moron and doing other, less important things in ...

Read More »

Getting Every Microsecond Out of uWSGI

In recent articles, I covered performance tuning both HAProxy and NGINX. Today’s article will be similar, however we’re going to go further down the stack and explore tuning a Python application running via uWSGI. What Is uWSGI In order to deploy a web application written in Python, you would typically need two supporting components. The first is a traditional web ...

Read More »

Multi-Line Lambdas in Python

I need to preface all of this with a disclaimer: I love Python, but I am able to see plenty of faults with it. In this article, I attempt to provide a very roundabout way of working around one of those faults: the lack of multi-line lambdas. This is not to say that this is a good solution, but it may ...

Read More »

Instance-Level Properties in Python

Making Descriptors that act as specialized properties can be tricky, especially when it comes to storing the data the property controls. I should know, I literally wrote the book. Looking at how other languages do it – especially Kotlin’s Delegated Properties – I felt that Python could use a system that works more like that. Delegated Properties are simply objects ...

Read More »

String Python Comparisons Along

Last time, I talked about Python’s boolean operators and and or and what can be confusing about them when “truthy” objects get into the mix. If you haven’t already read it, I would highly recommend it. This article is similar, but looks into something just a little different: the ability to string comparison operators. The Confusing Code Just like last ...

Read More »