Give it a go, I or any other moderator would be glad to advise, but you caught me in a generous moment for the last one.
Will always advise.
Hint use dictionaries for code lookup:
for example:
Will always advise.
Hint use dictionaries for code lookup:
for example:
class Codes: def __init__(self): self.GeologyCodes = { 'Well File Status': { 'PO': 'Producing Oil Well', 'PG': 'Producing Gas Well', 'DH': 'Dry Hole ', # Add rest of Well Status codes below 'AP': 'Permit to Drill' }, 'Classification': { 'O': 'Oil Well', 'G': 'Gas Well', # Rest of Classification codes below 'LW': 'LandOwner Water Well ' } # 'Land Types', 'County Codes', etc. below } # This dictionary can saved as a json file and recalles in any script that needs it: def print_code(self, cd_type, code): """ print_code(cd_type, code) Example: you get a well file status code from some data somewhere, and want to display that code :cd_type: Holds code type 'Well File Status', or 'Classification', etc. :code: Holds actual code like 'AP' :returns: None """ print(self.GeologyCodes[cd_type][code]) def try_status(self): """ try_status() test print_code :returns: None """ self.print_code('Well File Status', 'PG') code_type_from_file = 'Classification' code_from_file = 'LW' self.print_code(code_type_from_file, code_from_file) if __name__ == '__main__': cd = Codes() cd.try_status()results:
Output:[Running] python "i:\python\WellInfo\src\Codes.py"
Producing Gas Well
LandOwner Water Well
[Done] exited with code=0 in 0.054 seconds
Of course, dictionaries like this should be saved in appropriate directories as json data, and loaded when needed