本文整理汇总了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')
示例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
#.........这里部分代码省略.........