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
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
So, the original version of my print book ended up having a messed up cover. The color was off and there were strange artifacts all over. I was able to fix this, and the printers sent me a copy to verify that it truly was. Soooo, I now have an extra copy of my book, which I will now be giving away!
I’ll be doing a random drawing for it. To enter, simply send me an email at email@example.com that says something along the lines of “I wanna win!”. The last day to enter is May 25th. On the 26th, I will choose randomly from the emails, then email you back to get the address to send the book to. I will be covering shipping costs, so everything is completely free to you!
So here’s my attempt at accomplishing the closest thing possible toward making object literals in Python. Continue Reading
Hey readers! I finally finished publishing my book, Python Descriptors: A Comprehensive Guide! It is currently available on Lulu, and will eventually be available on Amazon, B&N, and other sites. It comes in both a Digest size paperback or ebook. So, go check it out and buy a copy, if you’d like!
For my followers, I’ll work on getting the deal out soon. Also, if anyone who has a blog, podcast, or other public content and would like to do a review of my book, I’ll get you a free pdf copy of the book to do the review from! Email me at firstname.lastname@example.org and let me know.
I’ll soon get an additional blurb on the site’s sidebar so that it’s easy to find a link to the book.
Today, I give you the second (and last) excerpt from my book, and it’s the last chapter. It brushes over some of the cooler examples of descriptors out there. It’s a short sample, and I feel kind of bad not giving you something juicier, but too much of the rest of the book has references to other chapters and discussed ideas, making it difficult to use as an excerpt. Continue Reading