dev-cafe / parselglossy

Generic input parsing library, speaking in tongues.
https://parselglossy.readthedocs.io
MIT License
7 stars 2 forks source link

Consider adding Union type #98

Closed robertodr closed 4 years ago

robertodr commented 4 years ago

I was thinking about cases where a given keyword might be either a list or just a scalar, that is Union[int, List[int]] (or similar) Do you think this is a good idea? I don't know exactly how it would look in the implementation.

bast commented 4 years ago

What would be an example for such a keyword?

robertodr commented 4 years ago

For example, when specifying states per irrep in a response calculation. I might either want to say explicitly 3 per irrep: [3, 3, 3, 3] or a total number. I admit it's a very narrow use case.

bast commented 4 years ago

We can add it but if this was my code, I would prefer:

num_states_per_irrep: [1, 2, 3, 4]
num_states_total: 10

or:

num_states_irrep:
    0: 1
    all: 10

I would not like to check inside whether something is a list type or not. I am not sure what would be better (less surprising, less error prone, explicit is better than implicit) from the user perspective.

robertodr commented 4 years ago

Shelving as: