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


Python Dictionary.Dictionary類代碼示例

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


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

示例1: action27

 def action27(self, lineNumber, symbol):
     dictionary = Dictionary()
     ss1 = SS1()
     if not dictionary.isFound(symbol):
         E.E(lineNumber, 0).unknownIdentifier(symbol)
     else:
         ss1.push(symbol)
開發者ID:vicpi,項目名稱:syntax-semantic-analyser,代碼行數:7,代碼來源:SemanticActions.py

示例2: get_dictionary

 def get_dictionary( ):
     """ Build a Dictionary based on the Diceware data. """
     
     dicto = Dictionary()
     
     print 'Parsing Diceware data...'
     i = 0;
     nLines = 7780
     
     # open file for reading
     with open(Diceware.fname, 'r') as fid:    
         for line in fid:
             tokens = Diceware.parse_line(line)
             if tokens is None:
                 continue
             
             # save data to list
             word = Word(tokens['word'], -1, -1, i);
             dicto.add_word(word)
             
             # increment counter and show progress
             i = i + 1;
             progress = float(i) / float(nLines)
             if (progress % 0.05) < 1e-4:
                 sys.stdout.write("\r%2.2f%%" %(progress*100))
                 sys.stdout.flush()
                 
     print '\nDone.'
     
     return dicto
開發者ID:watsonboyett,項目名稱:Sandbox,代碼行數:30,代碼來源:Diceware.py

示例3: action18

    def action18(self, lineNumber, symbol):
#        symbol = symbol['name']
        dictionary = Dictionary()
        ss1 = SS1()
        if dictionary.isFound(symbol):
            E.E(lineNumber, 0).doubleDefinition(symbol, 'procedure or function')
        ss1.push(symbol)
        ss1.push('proc_params')
開發者ID:vicpi,項目名稱:syntax-semantic-analyser,代碼行數:8,代碼來源:SemanticActions.py

示例4: action8000

    def action8000(self, lineNumber, symbol):
#        symbol = symbol['name']
        dictionary = Dictionary()
        if dictionary.isFound(symbol):
            E.E(lineNumber, 0).typeDoubleDefinition(symbol)
        _attrUserType = AtrClasses.AttrUserType(symbol)
        ss1 = SS1()
        ss1.push(_attrUserType)
開發者ID:vicpi,項目名稱:syntax-semantic-analyser,代碼行數:8,代碼來源:SemanticActions.py

示例5: action4000

    def action4000(self, lineNumber, symbol):
#        symbol = symbol['name']
        ss1 = SS1()
        value = ss1.pop()
        name = ss1.pop()
        name.bind(value)
        dictionary = Dictionary()
        dictionary.setObject(name.name, name)
開發者ID:vicpi,項目名稱:syntax-semantic-analyser,代碼行數:8,代碼來源:SemanticActions.py

示例6: action20000

    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,代碼行數:8,代碼來源:SemanticActions.py

示例7: action17000

    def action17000(self, lineNumber, symbol):
#        symbol = symbol['name']
        dictionary = Dictionary()
        if not dictionary.isFound(symbol):
            E.E(lineNumber, 0).typeUnknown(symbol)
        ss1 = SS1()
        _attrArray = ss1.pop()
        _attrArray['object'].setName(symbol)
        ss1.push( _attrArray )
開發者ID:vicpi,項目名稱:syntax-semantic-analyser,代碼行數:9,代碼來源:SemanticActions.py

示例8: test_get

 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,代碼行數:9,代碼來源:TestDictionary.py

示例9: action7000

    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,代碼行數:9,代碼來源:SemanticActions.py

示例10: action5000

    def action5000(self, lineNumber, symbol):
#        symbol = symbol['name']
        dictionary = Dictionary()
        if dictionary.isFound(symbol):
            E.E(lineNumber, 0).varDoubleDefinition(symbol)
        else:
            _attrVar = AtrClasses.AttrVar(symbol)
            ss1 = SS1()
            ss1.push(_attrVar)
開發者ID:vicpi,項目名稱:syntax-semantic-analyser,代碼行數:9,代碼來源:SemanticActions.py

示例11: test_pop

 def test_pop(self):
     d = Dictionary()
     d['raymond'] = 'red'
     d['rachel'] = 'blue'
     self.assertEqual(d.pop('rachel'), 'blue')
     self.assertEqual(d['raymond'], 'red')
     self.assertEqual(len(d), 1)
     with self.assertRaises(KeyError):
         d.pop('john')
開發者ID:milroc,項目名稱:Learning,代碼行數:9,代碼來源:TestDictionary.py

示例12: action6000

    def action6000(self, lineNumber, symbol):
#        symbol = symbol['name']        
        ss1 = SS1()
        dictionary = Dictionary()
        type = ss1.pop()
        while ss1.top() != None:
            name = ss1.pop()
            name.bindType(type['name'])
            dictionary.setObject(name.name, name)
        ss1.pop()
開發者ID:vicpi,項目名稱:syntax-semantic-analyser,代碼行數:10,代碼來源:SemanticActions.py

示例13: __init__

 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
開發者ID:awhawks,項目名稱:stiq,代碼行數:10,代碼來源:objectClass.py

示例14: Method

class Method(object):

    def __init__(self, aHt, aId, aCode, aLnotab, aIdClass, aArgs):
        self.hT = aHt
        self.locals = Dictionary(self.hT)
        self.argument = ()
        self.lnotab = aLnotab
        self.code = aCode
        self.name = aCode.co_name
        self.idClass = aIdClass
        self.Id = aId
        self.__updateArgument__(aArgs)

    def __getId__(self):
        return self.Id

    def __getLnotab__(self):
        return self.lnotab

    def __getLocals__(self):
        return self.locals

    def __getTarget__(self):
        return self.idClass

    def __getArgs__(self):
        return self.argument
    
    def __getArgsValues__(self, aLocals):
        argValues = ()
        for name in self.argument:
            if aLocals.has_key(name):
                argValues = argValues + (aLocals[name],)
        #TODO: analizar caso para cuando sean tuple, list, dict
        return argValues

    def __updateArgument__(self, aArgs):
        #no se registra self como argumento valido
        for theArg in aArgs:
            if not theArg == 'self':
                self.argument += (theArg,)
        theParentId = self.Id
        if self.hT.FLAG_DEBUGG:
            for theIndex in range(len(aArgs)):
                if not aArgs[theIndex] == 'self':
                    print self.hT.itsEvents['register'],
                    print self.hT.itsObjects['local'],
                    print theIndex + 1,
                    print theParentId,
                    print aArgs[theIndex]
                    raw_input() 
                    
    def __registerLocals__(self, aLocal):
        self.locals.__update__(aLocal,self.Id,self.argument)
開發者ID:awhawks,項目名稱:stiq,代碼行數:54,代碼來源:objectMethod.py

示例15: action55000

    def action55000(self, lineNumber, symbol):
#        symbol = symbol['name']
        dictionary = Dictionary()
        # @todo problem Fields in record cannot have name equal to usual variables
        if dictionary.isFound(symbol):
            E.E(lineNumber, 0).varDoubleDefinition(symbol)
        else:
            _attrVar = AtrClasses.AttrVar(symbol)
            ss1 = SS1()
            ss1.push(None)
            ss1.push(_attrVar)
開發者ID:vicpi,項目名稱:syntax-semantic-analyser,代碼行數:11,代碼來源:SemanticActions.py


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