Blog

Magic Method, on the wall, who, now, is the __fairest__ one of all?

Magic Method, on the wall, who, now, is the __fairest__ one of all? Update May 22: Here is the video of the talk: The Proposal This was my talk proposal for Pycon 2017 which got accepted. The proposal is slightly modified to match the final talk better. For example originally I was going to talk about writing a Redis Client too but I ended up removing that from the final talk. »

Subclassing dictionary in Python.

Subclassing dictionary in Python. Take a look at this: >>> c={'something': 2} >>> c.__dict__ Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'dict' object has no attribute '__dict__' Now let’s subclass dict: >>> class B(dict): ... def pass ... >>> b=B(something=2) >>> b {'something': 2} >>> b.__dict__ {} So dictionary don’t have __dict__ but if you subclass them, then they have __dict__. Interesting, eh? »

Harness the power of Python magic methods and lazy objects.

Harness the power of Python magic methods and lazy objects. This is based on a talk I gave at SoCal Python meetup. The PDF of this talk is available here. All the code is run in Python 3.5 but it works with Python 2 too. Overview When it comes to performance, lazy loading can help a lot. I remember when I first started using Django and Django’s lazy queries were magic to me. »

RedisWorks, the Pythonic Redis Client.

RedisWorks As a person who loves dynamic typing, I have always been frustrated with Py-Redis. It is a great library, but it is too low level. It maps the actual Redis commands directly. I always wanted to just say the.path = "something" and have it magically saved into Redis. Then somewhere else say print(the.path) and get the value from Redis. As simple as that! And here it is: RedisWorks »

Amazon S3 made simple for Python apps.

From time to time I need to do some simple file/folder transfer/query from a Python app to a S3 bucket. There is a great Python library called Boto that offers a comprehensive low level interface to AWS. I consider it too low level for simple operations on S3. On the other hand there is a fantastic command line library called s3cmd written in Python but it is designed to be used from command line and not from Python apps. »