I'm working on something that reads data from binary files. Data formats are often stored as integers that correspond to different types, and I typically interpret them by putting the possible types into tuples and indexing into them. Imagine A, B, and C are classes:
types = (A, B, C)
val = 0 # this would be read from the file
dataType = types[val]
Recently, I saw something that looked like a cleaner alternative to this online, but I can't remember anything specific about it and I haven't been able to find it again. This seems fine to me, but now I'm curious, is there a better way out there?