當前位置: 首頁>>代碼示例>>Python>>正文


Python Dictionary.get方法代碼示例

本文整理匯總了Python中Dictionary.Dictionary.get方法的典型用法代碼示例。如果您正苦於以下問題:Python Dictionary.get方法的具體用法?Python Dictionary.get怎麽用?Python Dictionary.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Dictionary.Dictionary的用法示例。


在下文中一共展示了Dictionary.get方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_get

# 需要導入模塊: from Dictionary import Dictionary [as 別名]
# 或者: from Dictionary.Dictionary import get [as 別名]
 def test_get(self):
     d = Dictionary()
     d['raymond'] = 'red'
     self.assertEqual(d['raymond'], 'red')
     d['rachel'] = 'blue'
     self.assertEqual(d['rachel'], 'blue')
     d['critter'] = 'yellow'
     self.assertEqual(d.get('raymond', 'not found'), 'red')
     self.assertEqual(d.get('john', 'not found'), 'not found')
開發者ID:milroc,項目名稱:Learning,代碼行數:11,代碼來源:TestDictionary.py

示例2: action20000

# 需要導入模塊: from Dictionary import Dictionary [as 別名]
# 或者: from Dictionary.Dictionary import get [as 別名]
    def action20000(self, lineNumber, symbol):
#        symbol = symbol['name']
        dictionary = Dictionary()
        if not dictionary.isFound(symbol):
            E.E(lineNumber, 0).typeUnknown(symbol)
        type = dictionary.get(symbol)
        ss1 = SS1()
        ss1.push(type)
開發者ID:vicpi,項目名稱:syntax-semantic-analyser,代碼行數:10,代碼來源:SemanticActions.py

示例3: action7000

# 需要導入模塊: from Dictionary import Dictionary [as 別名]
# 或者: from Dictionary.Dictionary import get [as 別名]
    def action7000(self, lineNumber, symbol):
#        symbol = symbol['name']
        ss1 = SS1()
        record = ss1.pop();
        dictionary = Dictionary()
        # @todo make interface for array, record, diapason and id
        _class = dictionary.get(record.name.name)['class']
        dictionary.setObject(record.name.name, record)
        row = self.getRow(record.name.name, _class, record)
開發者ID:vicpi,項目名稱:syntax-semantic-analyser,代碼行數:11,代碼來源:SemanticActions.py

示例4: getType

# 需要導入模塊: from Dictionary import Dictionary [as 別名]
# 或者: from Dictionary.Dictionary import get [as 別名]
 def getType(self, right):
     dictionary = Dictionary()
     isright = isinstance(right, AtrClasses.AttrElemAction) or isinstance(right, AtrClasses.AttrVar) or isinstance(right, AtrClasses.AttrIntConst) or isinstance(right, AtrClasses.AttrFloatConst)  or isinstance(right, AtrClasses.AttrStringConst) or isinstance(right, AtrClasses.AttrField) or isinstance(right, AtrClasses.AttrParam) or isinstance(right, AtrClasses.AttrRelation)
     if isright:
         rightType = right.type
     else:
         right = right.getValue()
         rightType = dictionary.get(right)
         if not rightType.has_key('object'): 
             E.E(self.lineNumber, 0).unknownIdentifier(right)
         rightType = rightType['object'].type
     return rightType
開發者ID:vicpi,項目名稱:syntax-semantic-analyser,代碼行數:14,代碼來源:SemanticActions.py

示例5: action21

# 需要導入模塊: from Dictionary import Dictionary [as 別名]
# 或者: from Dictionary.Dictionary import get [as 別名]
    def action21(self, lineNumber, symbol):
        ' not done '
#        symbol = symbol['name']
        dictionary = Dictionary()
        _attrProc = AtrClasses.AttrProc()
        ss1 = SS1()
        ss1.push(symbol)
        
        while not ss1.top() == 'proc_params':
            _type = ss1.pop()
            while not ss1.top() is None:
                attr = ss1.pop()
                attr.type = dictionary.get(symbol)
                _attrProc.addParam(attr)
            ss1.pop()
        ss1.pop()
        _name = ss1.pop()
        _attrProc.setName(_name)
        dictionary.setObject(_name, _attrProc)
        ss1.push(_attrProc)
開發者ID:vicpi,項目名稱:syntax-semantic-analyser,代碼行數:22,代碼來源:SemanticActions.py


注:本文中的Dictionary.Dictionary.get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。