4 ms·
I'm not really versed in the idioms/social mores of Python, so please take the following with a grain of salt: This seems like it usefully solves a problem, bu
by spedru 8y ago
I'm not really versed in the idioms/social mores of Python, so please take the following with a grain of salt:
This seems like it usefully solves a problem, but the invocation pattern is suspect to me -- Instead of "glom" taking the target for picking-apart plus a magic little bit of DSL, what if "glom" took a single parameter, the aforementioned DSL, and returned a function that would perform the corresponding search when called on a target? Even if Python or this package optimises away repeatedly searching (by the same spec|in the same manner), the convention the package prescribes is odd to me, right after the first few paragraphs of intro.
- seanc 8y agoPython regex library does this, optionally
- daturkel 8y agoSimilarly, statistical distributions in SciPy can be used in "frozen" form (pre-parameterized) or in a more general form where you supply the parameters at the same time you are requesting some attribute it the distribution. Seems to me to be a situation where one is useful if you expect reuse, and the other is useful if you don't.
- mhashemi 8y agoThe big, classical school of Python definitely prefers top-level functions. Still, I definitely understand that aesthetic, and am on board with not using functools.partial to achieve it. So: https://github.com/mahmoud/glom/issues/14 https://github.com/mahmoud/glom/issues/14 :)