In [1]:
Copied!
from placeholder import _ as x
x.real
from placeholder import _ as x
x.real
Out[1]:
F(operator.attrgetter('real'))
In [2]:
Copied!
nums = (0 + 2j), (1 + 1j), (2 + 0j)
min(nums, key=x.real)
nums = (0 + 2j), (1 + 1j), (2 + 0j)
min(nums, key=x.real)
Out[2]:
2j
In [3]:
Copied!
min(nums, key=x.imag)
min(nums, key=x.imag)
Out[3]:
(2+0j)
In [4]:
Copied!
x[0]
x[0]
Out[4]:
F(operator.itemgetter(0))
In [5]:
Copied!
pairs = 'ac', 'bb', 'ca'
min(pairs, key=x[0])
pairs = 'ac', 'bb', 'ca'
min(pairs, key=x[0])
Out[5]:
'ac'
In [6]:
Copied!
min(pairs, key=x[-1])
min(pairs, key=x[-1])
Out[6]:
'ca'
In [7]:
Copied!
import itertools
list(itertools.accumulate(range(1, 6), x * x))
import itertools
list(itertools.accumulate(range(1, 6), x * x))
Out[7]:
[1, 2, 6, 24, 120]
In [8]:
Copied!
list(itertools.filterfalse(x % 2, range(10)))
list(itertools.filterfalse(x % 2, range(10)))
Out[8]:
[0, 2, 4, 6, 8]
In [9]:
Copied!
list(filter(x % 2 == 0, range(10)))
list(filter(x % 2 == 0, range(10)))
Out[9]:
[0, 2, 4, 6, 8]
In [10]:
Copied!
list(filter(abs(x) < 1, [-1, 0, 1]))
list(filter(abs(x) < 1, [-1, 0, 1]))
Out[10]:
[0]
M
and m
(singleton)¶
Support for attrgetter(*)
, itemgetter(*)
, and methodcaller
.
In [11]:
Copied!
from placeholder import m
m('real', 'imag')
from placeholder import m
m('real', 'imag')
Out[11]:
F(operator.attrgetter('real', 'imag'))
In [12]:
Copied!
m[0, -1]
m[0, -1]
Out[12]:
F(operator.itemgetter(0, -1))
In [13]:
Copied!
m.split('-')
m.split('-')
Out[13]:
F(operator.methodcaller('split', '-'))