constantSorrow icon indicating copy to clipboard operation
constantSorrow copied to clipboard

Allow to get existing constants with __getitem__

Open cygnusv opened this issue 5 years ago • 3 comments

cygnusv avatar Feb 25 '20 06:02 cygnusv

Seems... reasonable I guess. What's the use case again? Obviously you want to be able to programmatically obtain the constant, but why?

jMyles avatar Apr 17 '20 02:04 jMyles

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()]

cygnusv avatar Apr 22 '20 00:04 cygnusv

What about getattr(constants, mode.upper())?

jMyles avatar Apr 22 '20 00:04 jMyles