Skip to content

Commit 3a0403c

Browse files
committed
Operator
1 parent f2f92b1 commit 3a0403c

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,7 +1306,7 @@ from functools import partial
13061306
LogicOp = Enum('LogicOp', {'AND': partial(lambda l, r: l and r),
13071307
'OR' : partial(lambda l, r: l or r)})
13081308
```
1309-
* **Another solution in this particular case, is to use `'and_'` and `'or_'` functions from module [operator](#operator) as values.**
1309+
* **Another solution in this particular case, is to use `'and_'` and `'or_'` functions from module [Operator](#operator) as values.**
13101310

13111311

13121312
Exceptions
@@ -2036,9 +2036,9 @@ from operator import itemgetter, attrgetter, methodcaller
20362036

20372037
```python
20382038
import operator as op
2039-
product_of_elems = functools.reduce(op.mul, <collection>)
20402039
sorted_by_second = sorted(<collection>, key=op.itemgetter(1))
20412040
sorted_by_both = sorted(<collection>, key=op.itemgetter(1, 0))
2041+
product_of_elems = functools.reduce(op.mul, <collection>)
20422042
LogicOp = enum.Enum('LogicOp', {'AND': op.and_, 'OR' : op.or_})
20432043
last_el = op.methodcaller('pop')(<list>)
20442044
```

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,7 +1211,7 @@ <h4 id="functionscannotbevaluessotheymustbewrapped">Functions can not be values,
12111211
<span class="hljs-string">'OR'</span> : partial(<span class="hljs-keyword">lambda</span> l, r: l <span class="hljs-keyword">or</span> r)})
12121212
</code></pre>
12131213
<ul>
1214-
<li><strong>Another solution in this particular case, is to use <code class="python hljs"><span class="hljs-string">'and_'</span></code> and <code class="python hljs"><span class="hljs-string">'or_'</span></code> functions from module <a href="#operator">operator</a> as values.</strong></li>
1214+
<li><strong>Another solution in this particular case, is to use <code class="python hljs"><span class="hljs-string">'and_'</span></code> and <code class="python hljs"><span class="hljs-string">'or_'</span></code> functions from module <a href="#operator">Operator</a> as values.</strong></li>
12151215
</ul>
12161216
<h2 id="exceptions"><a href="#exceptions" name="exceptions">#</a>Exceptions</h2>
12171217
<h3 id="basicexample">Basic Example</h3>
@@ -1755,9 +1755,9 @@ <h2 id="operator"><a href="#operator" name="operator">#</a>Operator</h2>
17551755
<span class="hljs-keyword">from</span> operator <span class="hljs-keyword">import</span> itemgetter, attrgetter, methodcaller
17561756
</code></pre>
17571757
<pre><code class="python language-python hljs"><span class="hljs-keyword">import</span> operator <span class="hljs-keyword">as</span> op
1758-
product_of_elems = functools.reduce(op.mul, &lt;collection&gt;)
17591758
sorted_by_second = sorted(&lt;collection&gt;, key=op.itemgetter(<span class="hljs-number">1</span>))
17601759
sorted_by_both = sorted(&lt;collection&gt;, key=op.itemgetter(<span class="hljs-number">1</span>, <span class="hljs-number">0</span>))
1760+
product_of_elems = functools.reduce(op.mul, &lt;collection&gt;)
17611761
LogicOp = enum.Enum(<span class="hljs-string">'LogicOp'</span>, {<span class="hljs-string">'AND'</span>: op.and_, <span class="hljs-string">'OR'</span> : op.or_})
17621762
last_el = op.methodcaller(<span class="hljs-string">'pop'</span>)(&lt;list&gt;)
17631763
</code></pre>

0 commit comments

Comments
 (0)