Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # I have a large number of variables defined as:
- PLUS = Operator(['+'])
- UPLUS = Operator(['+'], 50, Associativity.RIGHT, Arity.UNARY)
- MIN = Operator(['-'])
- UMIN = Operator(['-', '~'], 50, Associativity.RIGHT, Arity.UNARY)
- ...
- # Is there a way to group those variables into a list (without rewriting all their names - I'll likely be adding additional ones later, and it would be safer to only have to add them in one place)? I still need all of them as separate variables as well. The reason I need a list is because at some point I need to iterate through all of them.
- # In other words I want to avoid having to do this:
- PLUS = Operator(['+'])
- UPLUS = Operator(['+'], 50, Associativity.RIGHT, Arity.UNARY)
- ...
- operators = [PLUS, UPLUS, ...]
- # And instead do something like:
- operators = [
- PLUS = Operator (['+']),
- UPLUS = Operator(['+'], 50, Associativity.RIGHT, Arity.UNARY),
- ...
- ]
- # The above obviously does not work (throws a syntax error), but is there a way to accomplish this?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement