I use everything to print the names of the assigned IANA values in a package. Thus, all dictionaries have the same default value of "RESERVED".
I do not want to use d.get(key,default), but access to dictionaries with d[key], so if the key is not in d, it returns the default value (the same for all dictionaries).
I don't have to use dictionaries, but they were an intuitive choice ... Also, a dictionary where I could do this
d = {
1..16 = "RESERVED",
17 : "Foo",
18 : "Bar,
19..255: "INVALID"
}
It would be a preferred solution
Tuples may be another alternative, but then I tend to bias errors by assigning values ... (and my code will not be a “human readable”)
Oh yes, Python 2.4