c = {
"UNKNOWN_ERR" : 0,
"INDEX_SIZE_ERR" : 1,
"DOMSTRING_SIZE_ERR" : 2,
"HIERARCHY_REQUEST_ERR" : 3,
"WRONG_DOCUMENT_ERR" : 4,
"INVALID_CHARACTER_ERR" : 5,
"NO_DATA_ALLOWED_ERR" : 6,
"NO_MODIFICATION_ALLOWED_ERR" : 7,
"NOT_FOUND_ERR" : 8,
"NOT_SUPPORTED_ERR" : 9}
To get the value using the key is easy, I just use the key in c["UNKNOWN_ERR"]
to get 0
, given that all the values are unique is safe to get the key (message) from the value(errorcode).
Is there a standard way to do that or do I need to write a function that looks in all key and search that specific value?