我们从Python开源项目中,提取了以下12个代码示例,用于说明如何使用keyword.only_valid_as_leaf()。
def completion_names(evaluator, stmt, pos, module): keyword_list = all_keywords(evaluator) if not isinstance(stmt, Leaf) or has_inappropriate_leaf_keyword(pos, module): keyword_list = filter( lambda keyword: not keyword.only_valid_as_leaf, keyword_list ) return [keyword.name for keyword in keyword_list]
def only_valid_as_leaf(self): return self.name.value in keywords_only_valid_as_leaf