From 3a0403c96c0c554238dfa388d63467e5417b830e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Tue, 9 Jul 2019 17:01:11 +0200 Subject: [PATCH] Operator --- README.md | 4 ++-- index.html | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index cce493c..3d621f0 100644 --- a/README.md +++ b/README.md @@ -1306,7 +1306,7 @@ from functools import partial LogicOp = Enum('LogicOp', {'AND': partial(lambda l, r: l and r), 'OR' : partial(lambda l, r: l or r)}) ``` -* **Another solution in this particular case, is to use `'and_'` and `'or_'` functions from module [operator](#operator) as values.** +* **Another solution in this particular case, is to use `'and_'` and `'or_'` functions from module [Operator](#operator) as values.** Exceptions @@ -2036,9 +2036,9 @@ from operator import itemgetter, attrgetter, methodcaller ```python import operator as op -product_of_elems = functools.reduce(op.mul, ) sorted_by_second = sorted(, key=op.itemgetter(1)) sorted_by_both = sorted(, key=op.itemgetter(1, 0)) +product_of_elems = functools.reduce(op.mul, ) LogicOp = enum.Enum('LogicOp', {'AND': op.and_, 'OR' : op.or_}) last_el = op.methodcaller('pop')() ``` diff --git a/index.html b/index.html index b96db35..c122357 100644 --- a/index.html +++ b/index.html @@ -1211,7 +1211,7 @@ LogicOp = Enum('LogicOp', {'OR' : partial(lambda l, r: l or r)})
    -
  • Another solution in this particular case, is to use 'and_' and 'or_' functions from module operator as values.
  • +
  • Another solution in this particular case, is to use 'and_' and 'or_' functions from module Operator as values.

#Exceptions

Basic Example

@@ -1755,9 +1755,9 @@ MyMetaClass.__base__ == type # MyMetaClass is a from operator import itemgetter, attrgetter, methodcaller
import operator as op
-product_of_elems = functools.reduce(op.mul, <collection>)
 sorted_by_second = sorted(<collection>, key=op.itemgetter(1))
 sorted_by_both   = sorted(<collection>, key=op.itemgetter(1, 0))
+product_of_elems = functools.reduce(op.mul, <collection>)
 LogicOp          = enum.Enum('LogicOp', {'AND': op.and_, 'OR' : op.or_})
 last_el          = op.methodcaller('pop')(<list>)