Examples

F and _ (singleton)

from placeholder import _

_.real
F(operator.attrgetter('real'))
nums = (0 + 2j), (1 + 1j), (2 + 0j)
min(nums, key=_.real)
2j
min(nums, key=_.imag)
(2+0j)
_[0]
F(operator.itemgetter(0))
pairs = "ac", "bb", "ca"
min(pairs, key=_[0])
'ac'
min(pairs, key=_[-1])
'ca'
import itertools

list(itertools.accumulate(range(1, 6), _ * _))
[1, 2, 6, 24, 120]
list(itertools.filterfalse(_ % 2, range(10)))
[0, 2, 4, 6, 8]
list(filter(_ % 2 == 0, range(10)))
[0, 2, 4, 6, 8]
list(filter(abs(_) < 1, [-1, 0, 1]))
[0]

M and m (singleton)

Support for attrgetter(*), itemgetter(*), and methodcaller.

from placeholder import m

m("real", "imag")
F(operator.attrgetter('real', 'imag'))
m[0, -1]
F(operator.itemgetter(0, -1))
m.split("-")
operator.methodcaller('split', '-')