Skip to content

Commit cf5de3d

Browse files
committed
Operator
1 parent 60f1d2b commit cf5de3d

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2144,8 +2144,10 @@ sorted_by_second = sorted(<collection>, key=op.itemgetter(1))
21442144
sorted_by_both = sorted(<collection>, key=op.itemgetter(1, 0))
21452145
product_of_elems = functools.reduce(op.mul, <collection>)
21462146
union_of_sets = functools.reduce(op.or_, <coll_of_sets>)
2147-
last_el = op.methodcaller('pop')(<list>)
2147+
last_element = op.methodcaller('pop')(<list>)
21482148
```
2149+
* **Functions and\_() and or\_() correspond to operators '&' and '|'.**
2150+
* **They only work on objects with defined and() and or() special methods, ie. ints and sets.**
21492151

21502152

21512153
Introspection

index.html

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@
226226

227227
<body>
228228
<header>
229-
<aside>November 17, 2021</aside>
229+
<aside>November 19, 2021</aside>
230230
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
231231
</header>
232232

@@ -1916,8 +1916,12 @@
19161916
sorted_by_both = sorted(&lt;collection&gt;, key=op.itemgetter(<span class="hljs-number">1</span>, <span class="hljs-number">0</span>))
19171917
product_of_elems = functools.reduce(op.mul, &lt;collection&gt;)
19181918
union_of_sets = functools.reduce(op.or_, &lt;coll_of_sets&gt;)
1919-
last_el = op.methodcaller(<span class="hljs-string">'pop'</span>)(&lt;list&gt;)
1919+
last_element = op.methodcaller(<span class="hljs-string">'pop'</span>)(&lt;list&gt;)
19201920
</code></pre>
1921+
<ul>
1922+
<li><strong>Functions and_() and or_() correspond to operators '&amp;' and '|'.</strong></li>
1923+
<li><strong>They only work on objects with defined and() and or() special methods, ie. ints and sets.</strong></li>
1924+
</ul>
19211925
<div><h2 id="introspection"><a href="#introspection" name="introspection">#</a>Introspection</h2><p><strong>Inspecting code at runtime.</strong></p><div><h3 id="variables">Variables</h3><pre><code class="python language-python hljs">&lt;list&gt; = dir() <span class="hljs-comment"># Names of local variables (incl. functions).</span>
19221926
&lt;dict&gt; = vars() <span class="hljs-comment"># Dict of local variables. Also locals().</span>
19231927
&lt;dict&gt; = globals() <span class="hljs-comment"># Dict of global variables.</span>
@@ -3020,7 +3024,7 @@
30203024

30213025

30223026
<footer>
3023-
<aside>November 17, 2021</aside>
3027+
<aside>November 19, 2021</aside>
30243028
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
30253029
</footer>
30263030

0 commit comments

Comments
 (0)