当前位置: 首页>>代码示例>>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;未经允许,请勿转载。