当前位置: 首页>>代码示例>>Python>>正文


Python operator.not_方法代码示例

本文整理汇总了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) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:25,代码来源:webenginesettings.py

示例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) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:25,代码来源:test_bool.py

示例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 
开发者ID:neal-o-r,项目名称:aireamhan,代码行数:24,代码来源:__init__.py

示例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]) 
开发者ID:pyglet,项目名称:pyglet,代码行数:18,代码来源:cparser.py

示例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) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:24,代码来源:test_bool.py

示例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 
开发者ID:mbinary,项目名称:algorithm,代码行数:20,代码来源:parser.py

示例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)) 
开发者ID:akrylysov,项目名称:abrvalg,代码行数:8,代码来源:interpreter.py

示例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()) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:17,代码来源:test_richcmp.py

示例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()) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:17,代码来源:test_richcmp.py

示例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) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:16,代码来源:test_bool.py

示例11: __not__

# 需要导入模块: import operator [as 别名]
# 或者: from operator import not_ [as 别名]
def __not__(self):
        return self.apply_op1(operator.not_).binarize() 
开发者ID:xesscorp,项目名称:myhdlpeek,代码行数:4,代码来源:myhdlpeek.py

示例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]) 
开发者ID:pyglet,项目名称:pyglet,代码行数:14,代码来源:preprocessor.py

示例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 
开发者ID:ridwanmsharif,项目名称:lispy,代码行数:41,代码来源:eval.py

示例14: __not__

# 需要导入模块: import operator [as 别名]
# 或者: from operator import not_ [as 别名]
def __not__(self, other):
        return Expression((self, other), operator.not_) 
开发者ID:ebranca,项目名称:owasp-pysec,代码行数:4,代码来源:expr.py

示例15: __not__

# 需要导入模块: import operator [as 别名]
# 或者: from operator import not_ [as 别名]
def __not__(self): return type(self)(self, operator.not_) 
开发者ID:holoviz,项目名称:holoviews,代码行数:3,代码来源:transform.py


注:本文中的operator.not_方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。