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


Python Dictionary.update方法代码示例

本文整理汇总了Python中Dictionary.Dictionary.update方法的典型用法代码示例。如果您正苦于以下问题:Python Dictionary.update方法的具体用法?Python Dictionary.update怎么用?Python Dictionary.update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Dictionary.Dictionary的用法示例。


在下文中一共展示了Dictionary.update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_update

# 需要导入模块: from Dictionary import Dictionary [as 别名]
# 或者: from Dictionary.Dictionary import update [as 别名]
 def test_update(self):
     d = Dictionary()
     d.update([('raymond', 'red'), ('rachel', 'blue')])
     self.assertEqual(len(d), 2)
     self.assertEqual(d['raymond'], 'red')
     self.assertEqual(d['rachel'], 'blue')
开发者ID:milroc,项目名称:Learning,代码行数:8,代码来源:TestDictionary.py

示例2: Class

# 需要导入模块: from Dictionary import Dictionary [as 别名]
# 或者: from Dictionary.Dictionary import update [as 别名]
class Class(object):

    def __init__(self, aHt, aClassId, aCode, aLnotab):
        self.hT = aHt
        self.staticField = Dictionary(self.hT)
        self.attributes = Dictionary(self.hT)
        self.method = Dictionary(self.hT)
        self.lnotab = aLnotab
        self.code = aCode
        self.name = aCode.co_name
        self.Id = aClassId
        self.SpecialBehaviorId = -1

    def __getId__(self):
        return self.Id

    def __getLnotab__(self):
        return self.lnotab

    def __addMethod__(self, aCode, aLocals):
        for theKey,theValue in aLocals.iteritems():
            if inspect.isfunction(theValue):
                if not (theKey == '__module__'):
                    theId = self.hT.itsId.__get__()
                    self.method.update({theKey:theId})
                    self.hT.itsId.__next__()
    
    def __addSpecialMethod__(self, aFileName):
        if self.method.has_key("%sStaticMethod"%self.name):
            return
        theId = self.hT.itsId.__get__()
        self.method.update({"%sStaticMethod"%self.name:theId})
        self.hT.itsId.__next__()
        self.hT.__registerSpecialMethod__("%sStaticMethod"%self.name,
                                          theId,
                                          self.Id,
                                          aFileName)
        self.SpecialBehaviorId = theId
    
    def __setStaticField__(self,
                           aId,
                           aValue,
                           aFrameLineNo,
                           aCurrentLasti,
                           aParentTimestamp,
                           aDepth):
        theThreadId = self.hT.__getThreadId__(thread.get_ident())
        theCurrentTimestamp = self.hT.__convertTimestamp__(time.time())
        if not self.hT.itsProbe.has_key((aCurrentLasti, self.SpecialBehaviorId)):
            theProbeId = self.hT.__registerProbe__(aCurrentLasti,
                                              self.SpecialBehaviorId,
                                              aFrameLineNo)
        else:
            theProbeId = hT.itsProbe[(aCurrentLasti,aTheSpecialBehaviorId)]
        self.hT.itsPacker.reset()
        self.hT.itsPacker.pack_int(self.hT.itsEvents['set'])
        self.hT.itsPacker.pack_int(self.hT.itsObjects['classAttribute'])
        self.hT.itsPacker.pack_int(aId)
        theDataType = self.hT.__getDataType__(aValue)
        self.hT.itsPacker.pack_int(theDataType)
        thePackValue = self.hT.__packValue__(theDataType, aValue)
        self.hT.itsPacker.pack_int(theProbeId)
        self.hT.itsPacker.pack_hyper(aParentTimestamp)        
        self.hT.itsPacker.pack_int(aDepth)
        self.hT.itsPacker.pack_hyper(theCurrentTimestamp)
        self.hT.itsPacker.pack_int(theThreadId)
        if self.hT.FLAG_DEBUGG:
            print self.hT.itsEvents['set'],
            print self.hT.itsObjects['classAttribute'],
            print Id,
            print theDataType,
            print thePackValue,
            print theProbeId,
            print aParentTimestamp,
            print aCurrentDepth,
            print theCurrentTimestamp,
            print theThreadId
            raw_input()
        try:
            self.hT.itsSocket.sendall(self.hT.itsPacker.get_buffer())
            pass
        except:
            print 'TOD está durmiendo :-(', 'set static field'   
    
    def __register_set_StaticField__(self, 
                                     aLocals, 
                                     aFrameLineNo,
                                     aParentTimestamp,
                                     aDepth,
                                     aFileName):
        theLower = 0
        theUpper = len(self.code.co_code)
        theCode = self.code.co_code   
        while theLower < theUpper:
            theOp = ord(theCode[theLower])
            theNameOp = dis.opname[theOp]      
            theLower = theLower + 1
            if theOp >= dis.HAVE_ARGUMENT:
                theValue = ord(theCode[theLower])
                theValue += ord(theCode[theLower+1])*256
#.........这里部分代码省略.........
开发者ID:awhawks,项目名称:stiq,代码行数:103,代码来源:objectClass.py


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