<分区>
假设我有以下代码:
def validator(blacklist: list=['heck', 'muffins']):
def f(questionable_word: str) -> bool:
return questionable_word in blacklist
return f
validator_british = validator(['pish'])
validator_british('pish') # returns True
validator_british('heck') # returns False
我的问题是如何对 validator
函数进行类型提示,使其指示返回一个函数,特别是一个接受 str
并返回 bool
? f
函数的签名是:
def f(questionable_word: str) -> bool
validator
的 ???
位置应该放什么?
validator(blacklist: list=['heck', 'muffins']) -> ???: