Comment on Reasons to use protocol buffers instead of JSONparentComments−falcolas12yPython doesn't have enumerations, per se. Here's how I'd represent that: if 'edit' in structure['access']: # can edit In which case it really doesn't matter if there's junk in access. If I really felt the need to validate the structure, I could do so with: if not set(structure['access']).issubset(all_access_privs): raise ValueError('invalid access types passed in') but more realistically, I'd rely on the ORM object to validate against the authoritative source - the database - and key off the errors there.−TomaszZielinski12yPython 3.4 has enums, if that's what you meant: https://docs.python.org/3/library/enum.html
Comments
Python doesn't have enumerations, per se. Here's how I'd represent that:
In which case it really doesn't matter if there's junk in access. If I really felt the need to validate the structure, I could do so with: but more realistically, I'd rely on the ORM object to validate against the authoritative source - the database - and key off the errors there.Python 3.4 has enums, if that's what you meant: https://docs.python.org/3/library/enum.html