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


Python mydict.Dict类代码示例

本文整理汇总了Python中mydict.Dict的典型用法代码示例。如果您正苦于以下问题:Python Dict类的具体用法?Python Dict怎么用?Python Dict使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: update

    def update(self,d,strict=True):
        """Update current values with the specified settings

        Returns the sanitized update values.
        """
        ok = self.checkDict(d,strict)
        Dict.update(self,ok)
开发者ID:dladd,项目名称:pyFormex,代码行数:7,代码来源:canvas.py

示例2: __init__

    def __init__(self,kind=None,keys=None,set=None,type='FIELD',variable='PRESELECT',extra='',**options):
        """ Create new output request.

        - `type`: 'FIELD' or 'HISTORY'
        - `kind`: None, 'NODE', or 'ELEMENT' (first character suffices)
        - `extra`: an extra string to be added to the command line. This
          allows to add Abaqus options not handled by this constructor.
          The string will be appended to the command line preceded by a comma.

        For kind=='':

          - `variable`: 'ALL', 'PRESELECT' or ''
          
        For kind=='NODE' or 'ELEMENT':

          - `keys`: a list of output identifiers (compatible with kind type)
          - `set`: a single item or a list of items, where each item is either
            a property number or a node/element set name for which the results
            should be written. If no set is specified, the default is 'Nall'
            for kind=='NODE' and 'Eall' for kind='ELEMENT'
        """
        if 'history' in options:
            GD.warning("The `history` argument in an output request is deprecated.\nPlease use `type='history'` instead.")
        if 'numberinterval' in options:
            GD.warning("The `numberinterval` argument in an output request is deprecated.\nPlease use the `extra` argument instead.")

        if kind:
            kind = kind[0].upper()
        if set is None:
            set = "%sall" % kind
        Dict.__init__(self,{'kind':kind})
        if kind is None:
            self.update({'type':type,'variable':variable,'extra':extra})
        else:
            self.update({'keys':keys,'set':set})
开发者ID:BackupTheBerlios,项目名称:pyformex-svn,代码行数:35,代码来源:fe_abq.py

示例3: update

    def update(self, data={}, name=None, removeLocals=False):
        """Add a dictionary to the Config object.

        The data, if specified, should be a valid Python dict.
        If no name is specified, the data are added to the top dictionary
        and will become attributes.
        If a name is specified, the data are added to the named attribute,
        which should be a dictionary. If the name does not specify a
        dictionary, an empty one is created, deleting the existing attribute.

        If a name is specified, but no data, the effect is to add a new
        empty dictionary (section) with that name.

        If removeLocals is set, keys starting with '_' are removed from the
        data before updating the dictionary and not
        included in the config. This behaviour can be changed by setting
        removeLocals to false.
        """
        if removeLocals:
            for k in data.keys():
                if k[0] == "_":
                    del data[k]
        if name:
            if not self.has_key(name) or not isinstance(self[name], dict):
                self[name] = Dict()
            self[name].update(data)
        else:
            Dict.update(self, data)
开发者ID:BackupTheBerlios,项目名称:pyformex-svn,代码行数:28,代码来源:config.py

示例4: __init__

    def __init__(self,kind=None,keys=None,set=None,
                 type='FIELD',variable='PRESELECT'):
        """ Create new output request.
        
        kind = None, 'NODE', or 'ELEMENT' (first character suffices)

        For kind=='':

          type =  'FIELD' or 'HISTORY'
          variable = 'ALL' or 'PRESELECT'

        For kind=='NODE' or 'ELEMENT':

          keys is a list of output identifiers (compatible with kind type)
        
          set is single item or a list of items, where each item is either:
            - a property number
            - a node/elem set name
            for which the results should be written
          If no set is specified, the default is 'Nall' for kind=='NODE'
          and 'Eall' for kind='ELEMENT'
        """
        if kind:
            kind = kind[0].upper()
        if set is None:
            set = "%sall" % kind
        Dict.__init__(self,{'kind':kind})
        if kind is not None:
            self.update({'keys':keys,'set':set})
        else:
            self.update({'type':type,'variable':variable})
开发者ID:BackupTheBerlios,项目名称:pyformex-svn,代码行数:31,代码来源:fe_abq.py

示例5: __init__

    def __init__(self,coords,elems):
        """Create new model data.

        coords is an array with nodal coordinates
        elems is either a single element connectivity array, or a list of such.
        In a simple case, coords and elems can be the arrays obtained by 
        ``coords, elems = F.feModel()``.
        This is however limited to a model where all elements have the same
        number of nodes. Then you can use the list of elems arrays. The 'fe'
        plugin has a helper function to create this list. E.g., if ``FL`` is a
        list of Formices (possibly with different plexitude), then
        ``fe.mergeModels([Fi.feModel() for Fi in FL])``
        will return the (coords,elems) tuple to create the Model.

        The model can have node and element property numbers.
        """
        Dict.__init__(self)
        if not type(elems) == list:
            elems = [ elems ]
        self.coords = Coords(coords)
        self.elems = [ Connectivity(e) for e in elems ]
        nelems = [ e.nelems() for e in self.elems ]
        nplex = [ e.nplex() for e in self.elems ]
        self.celems = cumsum([0]+nelems)
        GD.message("Number of nodes: %s" % self.coords.shape[0])
        GD.message("Number of elements: %s" % self.celems[-1])
        GD.message("Number of element groups: %s" % len(nelems))
        GD.message("Number of elements per group: %s" % nelems)
        GD.message("Plexitude of each group: %s" % nplex)
开发者ID:BackupTheBerlios,项目名称:pyformex-svn,代码行数:29,代码来源:fe.py

示例6: __init__

 def __init__(self,mat='',sec=''):
     """Create a new properties database."""
     setMaterialDB(mat)
     setSectionDB(sec)
     Dict.__init__(self)
     self.prop = []
     self.nprop = []
     self.eprop = []
开发者ID:dladd,项目名称:pyFormex,代码行数:8,代码来源:properties.py

示例7: __init__

 def __init__(self):
     """Create a new properties database."""
     Dict.__init__(self)
     self.mats = MaterialDB()
     self.sect = SectionDB()
     self.prop = []
     self.nprop = []
     self.eprop = []
开发者ID:BackupTheBerlios,项目名称:pyformex-svn,代码行数:8,代码来源:properties.py

示例8: __delitem__

    def __delitem__(self,key):
        """Allows items to be delete with del self[section/key].

        """
        i = key.rfind('/')
        if i == -1:
            Dict.__delitem__(self,key)
        else:
            del self[key[:i]][key[i+1:]]
开发者ID:BackupTheBerlios,项目名称:pyformex-svn,代码行数:9,代码来源:config.py

示例9: __init__

    def __init__(self, data={}, default=None):
        """Creates a new Config instance.

        The configuration can be initialized with a dictionary, or
        with a variable that can be passed to the read() function.
        The latter includes the name of a config file, or a multiline string
        holding the contents of a configuration file.
        """
        Dict.__init__(self, default=default)
        if isinstance(data, dict):
            self.update(data)
        elif data:
            self.read(data)
开发者ID:BackupTheBerlios,项目名称:pyformex-svn,代码行数:13,代码来源:config.py

示例10: keys

    def keys(self,descend=True):
        """Return the keys in the config.

        By default this descends one level of Dicts.
        """
        keys = Dict.keys(self)
        if descend:
            for k,v in self.iteritems():
                if isinstance(v,Dict):
                    keys += ['%s/%s' % (k,ki) for ki in v.keys()]
                
        return keys
开发者ID:BackupTheBerlios,项目名称:pyformex-svn,代码行数:12,代码来源:config.py

示例11: __getitem__

    def __getitem__(self, key):
        """Allows items to be addressed as self[key].

        This is equivalent to the Dict lookup, except that items in
        subsections can also be retrieved with a single key of the format
        section/key.
        While this lookup mechanism works for nested subsections, the syntax
        for config files allows for only one level of sections!
        Also beware that because of this functions, no '/' should be used
        inside normal keys and sections names.
        """
        i = key.rfind("/")
        if i == -1:
            return Dict.__getitem__(self, key)
        else:
            try:
                return self[key[:i]][key[i + 1 :]]
            except KeyError:
                return self._default_(key)
开发者ID:BackupTheBerlios,项目名称:pyformex-svn,代码行数:19,代码来源:config.py

示例12: __init__

 def __init__(self,**kargs):
     """Create a new set of CanvasSettings."""
     Dict.__init__(self)
     self.reset(kargs)
开发者ID:dladd,项目名称:pyFormex,代码行数:4,代码来源:canvas.py


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