mahmoud / glom

☄️ Python's nested data operator (and CLI), for all your declarative restructuring needs. Got data? Glom it! ☄️
https://glom.readthedocs.io
Other
1.91k stars 63 forks source link

Fill used implicitly in T, Call, MExpr #155

Open kurtbrose opened 4 years ago

kurtbrose commented 4 years ago

there are places where values are interpreted as constants, except for a few special cases carved out

in all these cases, Fill() could be used instead:

so T and (1, T) would both work the same way -- Fill() basically says "walk down literals and mostly leave as-is, but if specs are present evaluate them"

The only "extra" thing that Fill does is call callables; not sure if this is okay as an intrinsic behavior, or if we should make something else that is like Fill but only recurses, doesn't do any calls.

kurtbrose commented 4 years ago

an example of how this might combine with MExpr

M((T.a, T.b)) == (1, 2)
kurtbrose commented 4 years ago

This may be applicable to default argument in a lot of places -- this would let us strike a middle-ground between "always spec" and "always a constant"

another place it could be useful is something like Let() or S() -- although currently those are "always spec"

kurtbrose commented 3 years ago

https://github.com/mahmoud/glom/pull/196 would cover this nicely