何もしない関数を指摘したいと思います。
def identity(*args)
return args
私のユースケースはこのようなものです
try:
gettext.find(...)
...
_ = gettext.gettext
else:
_ = identity
もちろん、identity
上記の定義を使用することもできますが、組み込みの方が確かに高速に実行されます(そして、自分で導入したバグを回避します)。
どうやら、map
そしてアイデンティティのためにfilter
使用しますNone
が、これはそれらの実装に固有です。
>>> _=None
>>> _("hello")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object is not callable
map(None, [1, 2, 3])
map and filter use None for the identity
ですか?