Category: Techniques

Python Immutability for Collection-Typed Attributes

I came across a situation recently where I wanted to preserve the immutability of lists of data that were being returned from a Python class. I held an implicit assumption that nothing in the code would change the content of the lists. But nothing enforced this assumption in the code, and the logic in the

Python: Old versus New Class Declaration

As a followup to my post on Checking Python Code with Pylint, here’s a look at what the effect is of using “new style” vs “old style” declaration when defining classes in Python. The ‘pylint’ checking tool for python complains that the “old style” class declaration is a “coding violation”. The sample code here declares

Checking Python Code with Pylint

These are a collection of notes from learning to use pylint to check the quality of Python code. I’ve been experimenting with Python recently; it’s become widely popular for data science applications (especially deep learning), and it’s also handy for the utility scripts that I often write (like trolling through logs, looking for interesting events

Running a Standalone HTTP Server

When developing and testing a new HTML page, it can be accessed locally by opening it as a file from a browser. But Chrome and Firefox will issue an error if the Javascript in the page tries to make an AJAX call (due to enforcement of browser sandbox security). To work around this there are