當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。