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
Lazy. Continue Reading
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
__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 from Kotlin, the original inspiration). These Delegated Properties can be designed very simply in a way that they only have to worry about the value on one instance, instead of figuring out how to store the value per instance. Continue Reading
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: Continue Reading
Some of you may know that Apress contacted me a little bit ago, wanting to publish my book under their brand. Well all the work is done now, and the book is up for sale on their web site, and soon it will be up on Amazon!
So go add the book to your wish lists!
Thanks for all your support, everyone. If I didn’t have a decent following, I’m not sure I would have written the book in the first place.
P.S. My second video is recorded. I just need to do some editing, and it will be put up soon.
This is going to be a short one to get me back into writing again. I just wanted to point out some interesting things I’ve noticed about Python inheritance that I’m (sometimes) sad that Java or C# don’t do. Continue Reading
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 be one of the best that we have for certain cases. Try and see if one of the typical workarounds is the best option before settling on this. Continue Reading
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. Continue Reading