bronx.stdtypes.dictionaries¶
Structure or dictionary like classes for miscellaneous usage.
Classes¶
- class bronx.stdtypes.dictionaries.Foo(**kw)[source]¶
Bases:
objectProtected C-struct like class… for gathering anything. Internal dict methods could be called through i_*methodname* protection.
- class bronx.stdtypes.dictionaries.LowerCaseDict(*kargs, **kwargs)[source]¶
Bases:
SpecialDictA dictionary with only lower case keys.
Example:
>>> lcdict = LowerCaseDict() >>> len(lcdict) 0 >>> lcdict['Ab'] = 1 >>> lcdict['cD'] = 2 >>> 'ab' in lcdict True >>> 'AB' in lcdict True >>> 'Ab' in lcdict True >>> 'abc' in lcdict False >>> print(','.join(sorted(lcdict.keys()))) ab,cd >>> lcdict.show() + ab = 1 + cd = 2
- class bronx.stdtypes.dictionaries.ReadOnlyDict(data=None)[source]¶
Bases:
MappingA type of read-only dictionary.
Example:
>>> rodict = ReadOnlyDict() >>> len(rodict) 0 >>> rodict['a'] = 1 Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'ReadOnlyDict' object does not support item assignment >>> rodict = ReadOnlyDict(dict(a=1, b=2)) >>> len(rodict) 2 >>> rodict['a'] 1 >>> print(','.join(rodict)) a,b >>> print(','.join([str(x) for k, x in sorted(rodict.items())])) 1,2
- class bronx.stdtypes.dictionaries.SpecialDict(*kargs, **kwargs)[source]¶
Bases:
dictAdd some special features to std dict especially the ability to remap keys on the fly.
This class behaves like a usual dictionary, to be useful, it should be subclassed and the method
remap()should be redefined in order to implement a customised key remaping
- class bronx.stdtypes.dictionaries.UpperCaseDict(*kargs, **kwargs)[source]¶
Bases:
SpecialDictA dictionary with only upper case keys.