You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* pandas dataframes (if pandas is present): `df` (from `mini_lambda.pandas`)
30
30
31
31
32
32
## Lambda Expressions vs Lambda Functions
@@ -148,14 +148,15 @@ or through provided workarounds :
148
148
149
149
```python
150
150
from mini_lambda import b, i, s, l, x
151
-
from mini_lambda import Slice, Get, Not, In
151
+
from mini_lambda import Slice, Get, Not, In, And
152
152
from mini_lambda import Iter, Repr, Format, Len, Int, Any, Log, DDecimal
153
153
from math import log
154
154
from decimal import Decimal
155
155
156
156
# boolean logic
157
157
expr = (x >1) and (x <5) # fails
158
158
expr = (x >1) & (x <5) # OK
159
+
expr = And(x >1, x <5) # OK
159
160
# iterating
160
161
expr =next(iter(s)) # fails
161
162
expr =next(Iter(s)) # OK
@@ -207,7 +208,7 @@ As seen above, there are several types of defective behaviours:
207
208
208
209
* built-in behaviours with special syntax (`not b`, `{'a': 1}[s]`, `x in y`, `any_(x)`). In which case an equivalent explicit method is provided: `Not`, `Get`, `Slice`, `In`, `Any`, `All`. In addition, equivalent methods `<expr>.contains()`, `<expr>.is_in()`, `<expr>.not_()`, `<expr>.any_()`, and `<expr>.all_()` are provided.
209
210
210
-
* the shortcircuit boolean operators `and/or` can not be overriden and check the return type, so you should use `&` or `|`instead
211
+
* the shortcircuit boolean operators `and/or` can not be overridden and check the return type, so you should use either bitwise combination (`&` or `|`) or logical (`And` or `Or`) instead.
211
212
212
213
* any other 'standard' methods, whether they are object constructors `Decimal()` or functions such as `log()`. We will see in the next section how you can convert any existing class or method to a lambda-friendly one. `mini_lambda` comes bundled with a few of them, namely all constants, functions and classes defined in `math` and `decimal` modules.
213
214
@@ -344,7 +345,8 @@ Note: although the above is valid, it is much more recommended to convert the wh
344
345
Classes can be entirely made lambda-friendly at once. This will convert the constructor, as well as any other method that would be available.
345
346
346
347
```python
347
-
from mini_lambda import X, _, make_lambda_friendly_class
348
+
from mini_lambda import _, make_lambda_friendly_class
Actually the `Constant()` (alias `C()` or `make_lambda_friendly()`) function that we saw above to convert constants, is also able to convert methods ans classes. So if there is only a single conversion operator to remember, remember this one.
0 commit comments