Home » Archives for Jacob Zimmerman

Author Archives: Jacob Zimmerman

Jacob is a certified Java programmer (level 1) and Python enthusiast. He loves to solve large problems with programming and considers himself pretty good at design.

Better Unbound Python Descriptors

Welcome back from another hiatus! This post is a facepalm post because I recently realized that I’ve been an idiot for so long. I have a tendency to make things more complicated than they need to be, as can be seen in my articles about instance properties. I’ve briefly mentioned unbound attributes (Class.attr returns a function that you pass an ...

Read More »

Using the New Python Instance Properties

Last week, I showed you my new implementation for instance-level properties in Python. This week, we’ll take another look at it by implementing a few Delegated Properties and helpers to make using them just a hair nicer. Recreating Kotlin’s Built-In Delegates For inspiration of what Delegated Properties to create, we’ll start by recreating the ones built into Kotlin, starting with ...

Read More »

Another Look at Instance-Level Properties in Python

A while back, I did a post on making instance-level properties in Python where the implementation of it required inheritance as well as messing with __getattribute__() and __setattr__(), which are a little dangerous to mess with. Then I had another idea last night (as of the time of writing this): Use normal descriptors to delegate to “Delegated Properties” (name taken ...

Read More »

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 »

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 »