Pseudo-Immutable Dictionaries in Python

2013 Jan04


very so often a situation arises where you need to keeps some small bits of data around where you know the value, and want to ensure that it won't get fudged with in the lifespan of the application. Say, for example, you want to map some Classes to some known values for quick lookup to dynamically generate some output - Like a dynamic django form In other words, you want ENUMS.

Python doesn't have an implementation for ENUMS, and most of the standard data types are mutable, which doesn't sit well in this situation. Usually, the python swiss army knife - The Dictionary is a one size fits all solution. But, being a mutable type, don't quite fit the

Read More