本文整理汇总了Python中operator.not_方法的典型用法代码示例。如果您正苦于以下问题:Python operator.not_方法的具体用法?Python operator.not_怎么用?Python operator.not_使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类operator
的用法示例。
在下文中一共展示了operator.not_方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import operator [as 别名]
# 或者: from operator import not_ [as 别名]
def __init__(self, settings):
super().__init__(settings)
# Attributes which don't exist in all Qt versions.
new_attributes = {
# Qt 5.8
'content.print_element_backgrounds':
('PrintElementBackgrounds', None),
# Qt 5.11
'content.autoplay':
('PlaybackRequiresUserGesture', operator.not_),
# Qt 5.12
'content.dns_prefetch':
('DnsPrefetchEnabled', None),
}
for name, (attribute, converter) in new_attributes.items():
try:
value = getattr(QWebEngineSettings, attribute)
except AttributeError:
continue
self._ATTRIBUTES[name] = Attr(value, converter=converter)
示例2: test_operator
# 需要导入模块: import operator [as 别名]
# 或者: from operator import not_ [as 别名]
def test_operator(self):
import operator
self.assertIs(operator.truth(0), False)
self.assertIs(operator.truth(1), True)
with test_support.check_py3k_warnings():
self.assertIs(operator.isCallable(0), False)
self.assertIs(operator.isCallable(len), True)
self.assertIs(operator.isNumberType(None), False)
self.assertIs(operator.isNumberType(0), True)
self.assertIs(operator.not_(1), False)
self.assertIs(operator.not_(0), True)
self.assertIs(operator.isSequenceType(0), False)
self.assertIs(operator.isSequenceType([]), True)
self.assertIs(operator.contains([], 1), False)
self.assertIs(operator.contains([1], 1), True)
self.assertIs(operator.isMappingType(1), False)
self.assertIs(operator.isMappingType({}), True)
self.assertIs(operator.lt(0, 0), False)
self.assertIs(operator.lt(0, 1), True)
self.assertIs(operator.is_(True, True), True)
self.assertIs(operator.is_(True, False), False)
self.assertIs(operator.is_not(True, True), False)
self.assertIs(operator.is_not(True, False), True)
示例3: add_globals
# 需要导入模块: import operator [as 别名]
# 或者: from operator import not_ [as 别名]
def add_globals(self):
"Add some Scheme standard procedures."
import math, cmath, operator as op
from functools import reduce
self.update(vars(math))
self.update(vars(cmath))
self.update({
'+':op.add, '-':op.sub, '*':op.mul, '/':op.itruediv, 'níl':op.not_, 'agus':op.and_,
'>':op.gt, '<':op.lt, '>=':op.ge, '<=':op.le, '=':op.eq, 'mod':op.mod,
'frmh':cmath.sqrt, 'dearbhluach':abs, 'uas':max, 'íos':min,
'cothrom_le?':op.eq, 'ionann?':op.is_, 'fad':len, 'cons':cons,
'ceann':lambda x:x[0], 'tóin':lambda x:x[1:], 'iarcheangail':op.add,
'liosta':lambda *x:list(x), 'liosta?': lambda x:isa(x,list),
'folamh?':lambda x: x == [], 'adamh?':lambda x: not((isa(x, list)) or (x == None)),
'boole?':lambda x: isa(x, bool), 'scag':lambda f, x: list(filter(f, x)),
'cuir_le':lambda proc,l: proc(*l), 'mapáil':lambda p, x: list(map(p, x)),
'lódáil':lambda fn: load(fn), 'léigh':lambda f: f.read(),
'oscail_comhad_ionchuir':open,'dún_comhad_ionchuir':lambda p: p.file.close(),
'oscail_comhad_aschur':lambda f:open(f,'w'), 'dún_comhad_aschur':lambda p: p.close(),
'dac?':lambda x:x is eof_object, 'luacháil':lambda x: evaluate(x),
'scríobh':lambda x,port=sys.stdout:port.write(to_string(x) + '\n')})
return self
示例4: p_unary_operator
# 需要导入模块: import operator [as 别名]
# 或者: from operator import not_ [as 别名]
def p_unary_operator(p):
'''unary_operator : '&'
| '*'
| '+'
| '-'
| '~'
| '!'
'''
# reduces to (op, op_str)
p[0] = ({
'+': operator.pos,
'-': operator.neg,
'~': operator.inv,
'!': operator.not_,
'&': 'AddressOfUnaryOperator',
'*': 'DereferenceUnaryOperator'}[p[1]], p[1])
示例5: test_operator
# 需要导入模块: import operator [as 别名]
# 或者: from operator import not_ [as 别名]
def test_operator(self):
import operator
self.assertIs(operator.truth(0), False)
self.assertIs(operator.truth(1), True)
self.assertIs(operator.isCallable(0), False)
self.assertIs(operator.isCallable(len), True)
self.assertIs(operator.isNumberType(None), False)
self.assertIs(operator.isNumberType(0), True)
self.assertIs(operator.not_(1), False)
self.assertIs(operator.not_(0), True)
self.assertIs(operator.isSequenceType(0), False)
self.assertIs(operator.isSequenceType([]), True)
self.assertIs(operator.contains([], 1), False)
self.assertIs(operator.contains([1], 1), True)
self.assertIs(operator.isMappingType(1), False)
self.assertIs(operator.isMappingType({}), True)
self.assertIs(operator.lt(0, 0), False)
self.assertIs(operator.lt(0, 1), True)
self.assertIs(operator.is_(True, True), True)
self.assertIs(operator.is_(True, False), False)
self.assertIs(operator.is_not(True, True), False)
self.assertIs(operator.is_not(True, False), True)
示例6: __init__
# 需要导入模块: import operator [as 别名]
# 或者: from operator import not_ [as 别名]
def __init__(self,tokens=None,syms=None,codes=None,level=0):
'''init pc, closure, reserved keywords, operators'''
super().__init__()
self.reserved={'FUNC','PRINT','RETURN','BEGIN','END','IF','THEN','FOR','ELIF','ELSE','WHILE','DO','BREAK','CONTINUE','VAR','CONST','ODD','RANDOM','SWITCH','CASE','DEFAULT'}
self.bodyFirst= self.reserved.copy()
self.bodyFirst.remove('ODD')
self.relationOPR= {'EQ':eq,'NEQ':ne,'GT':gt,'LT':lt,'GE':ge,'LE':le} # odd
self.conditionOPR = {'AND':and_,'OR':or_, 'NOT':not_}
self.conditionOPR.update(self.relationOPR)
self.arithmeticOPR = {'ADD':add,'SUB':sub,'MOD':mod,'MUL':mul,'POW':pow,'DIV':lambda x,y:x/y,'INTDIV':lambda x,y:round(x)//round(y) }
self.bitOPR = {'LSHIFT':lambda x,y:round(x)<<round(y),'RSHIFT':lambda x,y:round(x)>>round(y),'BITAND':lambda x,y:round(x)&round(y), 'BITOR':lambda x,y:round(x)|round(y),'BITNOT':lambda x:~round(x)}
self.binaryOPR = dict()
self.binaryOPR.update(self.conditionOPR)
del self.binaryOPR['NOT']
self.binaryOPR.update(self.arithmeticOPR)
self.binaryOPR.update(self.bitOPR)
del self.binaryOPR['BITNOT']
self.unaryOPR = {'NEG':neg,'NOT':not_,'BITNOT':lambda x:~round(x),'FAC':lambda x:reduce(mul,range(1,round(x)+1),1),'ODD':lambda x:round(x)%2==1, 'RND':lambda x:randint(0,x),'INT':round}#abs
示例7: eval_unary_operator
# 需要导入模块: import operator [as 别名]
# 或者: from operator import not_ [as 别名]
def eval_unary_operator(node, env):
operations = {
'-': operator.neg,
'!': operator.not_,
}
return operations[node.operator](eval_expression(node.right, env))
示例8: test_not
# 需要导入模块: import operator [as 别名]
# 或者: from operator import not_ [as 别名]
def test_not(self):
# Check that exceptions in __nonzero__ are properly
# propagated by the not operator
import operator
class Exc(Exception):
pass
class Bad:
def __nonzero__(self):
raise Exc
def do(bad):
not bad
for func in (do, operator.not_):
self.assertRaises(Exc, func, Bad())
示例9: test_not
# 需要导入模块: import operator [as 别名]
# 或者: from operator import not_ [as 别名]
def test_not(self):
# Check that exceptions in __bool__ are properly
# propagated by the not operator
import operator
class Exc(Exception):
pass
class Bad:
def __bool__(self):
raise Exc
def do(bad):
not bad
for func in (do, operator.not_):
self.assertRaises(Exc, func, Bad())
示例10: test_operator
# 需要导入模块: import operator [as 别名]
# 或者: from operator import not_ [as 别名]
def test_operator(self):
import operator
self.assertIs(operator.truth(0), False)
self.assertIs(operator.truth(1), True)
self.assertIs(operator.not_(1), False)
self.assertIs(operator.not_(0), True)
self.assertIs(operator.contains([], 1), False)
self.assertIs(operator.contains([1], 1), True)
self.assertIs(operator.lt(0, 0), False)
self.assertIs(operator.lt(0, 1), True)
self.assertIs(operator.is_(True, True), True)
self.assertIs(operator.is_(True, False), False)
self.assertIs(operator.is_not(True, True), False)
self.assertIs(operator.is_not(True, False), True)
示例11: __not__
# 需要导入模块: import operator [as 别名]
# 或者: from operator import not_ [as 别名]
def __not__(self):
return self.apply_op1(operator.not_).binarize()
示例12: p_unary_operator
# 需要导入模块: import operator [as 别名]
# 或者: from operator import not_ [as 别名]
def p_unary_operator(self, p):
'''unary_operator : '+'
| '-'
| '~'
| '!'
'''
# reduces to (op, op_str)
p[0] = ({
'+': operator.pos,
'-': operator.neg,
'~': operator.inv,
'!': operator.not_}[p[1]], p[1])
示例13: standard_env
# 需要导入模块: import operator [as 别名]
# 或者: from operator import not_ [as 别名]
def standard_env():
env = Env()
env.update(vars(math))
env.update({
'+':op.add,
'-':op.sub,
'*':op.mul,
'/':op.div,
'>':op.gt,
'<':op.lt,
'>=':op.ge,
'<=':op.le,
'=':op.eq,
'abs': abs,
'append': op.add,
'apply': apply,
'begin': lambda *x: x[-1],
'car': lambda x: x[0],
'cdr': lambda x: x[1:],
'cons': lambda x,y: [x] + y,
'eq?': op.is_,
'equal?': op.eq,
'length': len,
'list': lambda *x: list(x),
'list?': lambda x: isinstance(x,list),
'map': map,
'max': max,
'filter': filter,
'foldr': foldr,
'foldl': foldl,
'min': min,
'not': op.not_,
'null?': lambda x: x == [],
'number?': lambda x: isinstance(x, Number),
'procedure?': callable,
'round': round,
'symbol?': lambda x: isinstance(x, Symbol),
})
return env
示例14: __not__
# 需要导入模块: import operator [as 别名]
# 或者: from operator import not_ [as 别名]
def __not__(self, other):
return Expression((self, other), operator.not_)
示例15: __not__
# 需要导入模块: import operator [as 别名]
# 或者: from operator import not_ [as 别名]
def __not__(self): return type(self)(self, operator.not_)