Forwarded from dnaugsuz
其实还可以这么写,如果不嫌没必要的话:
不过就代码复用比可读性来看,这么做意义不大
from itertools import chain
from pathlib import Path
def chain_method_result_iters(op):
def __call__(self, *args):
invoke = lambda it: op(self, it)
return chain.from_iterable( map(invoke, args) )
return __call__
merge_glob = chain_method_result_iters(Path.glob) list(merge_glob(Path("/tmp"), "*.xpi", "*.1000")) 结果同上不用高阶函数的版本不过就代码复用比可读性来看,这么做意义不大
Forwarded from dnaugsuz
看来 Python 的 core devs 还是一群文艺青年,我还以为导入这个模块可以提供
this 字面名呢Forwarded from dnaugsuz
Complex is better than complicated.
是啊,可是 self 哪里比 implicit this (实际上有点像作用域策略) 更 *不* complicated 的了?
是啊,可是 self 哪里比 implicit this (实际上有点像作用域策略) 更 *不* complicated 的了?
Forwarded from dnaugsuz
Forwarded from dnaugsuz
以前 C 的时候人们就喜欢用
SomeClass_someMethod(struct SomeClass*, int arg1) 这种方式来实现“面向对象”Forwarded from 任桑 今天开始做魔王
一会儿python不太面向对象,一会儿比python懂编程,一会儿复制粘贴一份代码过来然后说这是xx写的你也配批评?