Python是关于简单易读的代码.它比版本更好,我是一个巨大的粉丝!但是,l
a
m
b
d
a
每次我必须键入lambda时输入并不好玩(你可能不同意).问题是,l
a
m
b
d
a
当我在map
s和filter
s中嵌入几个lambdas时,这6个字符使我的语句更长(我没有嵌套超过2或3,因为它消除了python的可读性 - 这里没有参数!)
# How to rename/alias a keyword to a nicer one?
lines = map(lmbd x: x.strip(), sys.stdin)
# OR, better yet, how to define my own operator like -> in python?
lines = map(x -> x.strip(), sys.stdin)
# Or may be :: operator is pythonic
lines = map(x :: x.strip(), sys.stdin)
# INSTEAD of this ugly one. Taking …
Run Code Online (Sandbox Code Playgroud)