constantSorrow
constantSorrow copied to clipboard
Allow to get existing constants with __getitem__
Seems... reasonable I guess. What's the use case again? Obviously you want to be able to programmatically obtain the constant, but why?
The use case that made me think of this was that we use constant sorrow to define the possible contract deployment modes (BARE, IDLE, FULL) and in the CLI there's a --mode option that allows you to specify it.
Currently, as there's no support for what this PR does, in the CLI code we have to do:
deployment_mode = constants.__getattr__(mode.upper())
It would be cleaner to do:
deployment_mode = constants[mode.upper()]
What about getattr(constants, mode.upper())?