Closed jim108dev closed 2 months ago
Thanks for the input. Returns looks like a great and well made library for Python. This library (Expression) tries to stay close to F# abstractions and naming, i.e by using Expression you will learn some F# as well. But I don't think we should try to compare ourselves with others. I really don't know Returns and have never used it myself.
Hi @dbrattli, thanks for the reply. What I really do a lot lately is piping with pandas and it is not type safe with pylance.,e. g.
df_train_features = (df_train_source.pipe(filter_value, "Month", 9)
.pipe(filter_columns, FEATURES)
.pipe(dropna)
)
Does Expression offer a solution for that?
Yes, I think so. But you would need to craft your handlers so that you can partially apply them (when they need multiple arguments) e.g:
I see. On the readme it says: "Avoid currying, not supported in Python by default and not a well known concept by Python programmers." Does this mean I have to write inner functions for most of my functions now?
Maybe. The problem with currying is that the function also looses it's type. But there's perhaps another solution. Let me check ...
Well, piping only works with functions taking a single argument, so we need to turn the handlers into single argument functions. Currying or applying a function partially is not really the normal way of programming in Python, but e.g. decorations are commonly used (returning inner functions). So a few non-magic decorators could do the trick. I'm considering adding these decorators #49 that should hopefully do the trick.
The biggest difference I think is that expression
supports pylance
, but returns
only supports mypy
.
Hi! Thank you for creating this repo. I was wondering what exactly are the pros and cons opposite to https://github.com/dry-python/returns. Maybe someone could make this more clear in the Readme.
Thank you!