From cf5de3d934cf5cbba24f8280a9c72f664e0aeaff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Fri, 19 Nov 2021 14:30:09 +0100 Subject: [PATCH] Operator --- README.md | 4 +++- index.html | 10 +++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9d483ba..e43ebb5 100644 --- a/README.md +++ b/README.md @@ -2144,8 +2144,10 @@ sorted_by_second = sorted(, key=op.itemgetter(1)) sorted_by_both = sorted(, key=op.itemgetter(1, 0)) product_of_elems = functools.reduce(op.mul, ) union_of_sets = functools.reduce(op.or_, ) -last_el = op.methodcaller('pop')() +last_element = op.methodcaller('pop')() ``` +* **Functions and\_() and or\_() correspond to operators '&' and '|'.** +* **They only work on objects with defined and() and or() special methods, ie. ints and sets.** Introspection diff --git a/index.html b/index.html index af84aeb..08b9223 100644 --- a/index.html +++ b/index.html @@ -226,7 +226,7 @@ pre.prettyprint {
- +
@@ -1916,8 +1916,12 @@ sorted_by_second = sorted(<collection>, key=op.itemgetter(1, 0)) product_of_elems = functools.reduce(op.mul, <collection>) union_of_sets = functools.reduce(op.or_, <coll_of_sets>) -last_el = op.methodcaller('pop')(<list>) +last_element = op.methodcaller('pop')(<list>) +
    +
  • Functions and_() and or_() correspond to operators '&' and '|'.
  • +
  • They only work on objects with defined and() and or() special methods, ie. ints and sets.
  • +

#Introspection

Inspecting code at runtime.

Variables

<list> = dir()                             # Names of local variables (incl. functions).
 <dict> = vars()                            # Dict of local variables. Also locals().
 <dict> = globals()                         # Dict of global variables.
@@ -3020,7 +3024,7 @@ $ pyinstaller script.py --add-data '<path>:.'