r(限制的)e(扩展的)对象。简单、合理、快速、受限/扩展的python对象。
ReOBJ的Python项目详细描述
答复:
r(限制的)e(扩展的)对象。简单、合理、快速、受限/扩展的python对象。
Main Info
reobj包含不同的受限/扩展python对象。
- redicts:简单、合理、快速、受限/扩展的python字典对象。
- relists:简单、合理、快速、受限/扩展的列表对象。
- retuples:简单、合理、快速、受限/扩展元组对象。
- rematrixs:简单、合理、快速、受限/扩展的元组对象列表。
all`rebase类-子类`:
Warning
for all ReBASE classes disabled methods
any class.copy()
- e.g.: xy = myrlist.copy()
任何类。清除()
- e.g.: myrlist.clear()
任何设置属性
任何
任何“添加”
可以用json转储:但会丢失任何额外的数据,如:键顺序(list)或/和任何额外数据dict
可腌制
其他方法:
set_extra_data(), update_extra_data(), replace_extra_data(): Sets/updates key/value to the additional dictionary: extra_data
copy_recursively(): recursively copy: Supports recursively intermediate ReDICT, ReLIST, ReTUPLE, dicts, lists and tuples (and their subclasses: depending on there implementation though)
- this will also copy any ReDICT / ReLIST / ReTUPLE / ReMATRIX extra_data dict and any key_order (list) and any extra_key_order (list)
递归复制到python本地类型::递归复制:将所有ReOBJ更改为本地python类型
RdictIO, RdictFO, RdictFO2: to python `OrderedDict obj keeping their order (see also argument: use_extra_key_order)
all other ReDICT: objects will be replaced by normal python dict objs
all ReLIST obj will be replaced by normal python list objs
all ReTUPLE obj will be replaced by normal python tuple objs
all ReMATRIX obj will be replaced by normal python list of tuple objs
Warning
ReMATRIX tuple items (rows) are not recursively copied so there should be no dict, list ect.. just basic types
递归地支持中间ReDICT、ReLIST、ReTUPLE、dict、list和tuple(以及它们的子类:取决于它们的实现)
注意
任何ReOBJ集合:额外数据将丢失
topickle():从obj返回一个新的pickled dumps字节字符串
tojson():从obj返回一个新的json转储字符串
tojson_keeporder():从obj中返回一个新的json dumps字符串,保持任何rdictio、rdictfo、rdictfo2的顺序
- this uses first the: copy_recursively_to_python_native_types()
警告
比较不考虑任何键顺序(list)或额外数据dict
ReDICT
概述差异
Edict类似于普通的python dict,但具有一些附加(扩展)功能
Rdict和RdictIO:可以在创建/初始化后添加新项
RdictF和RdictFO,RdictFO2:F(ix)无法在创建/初始化后添加新项
rdict和rdictf:没有任何键顺序(list)或任何额外键顺序(list)
rdictio和rdictfo,rdictfo2:o(o rder)有一个键顺序(list)加上一个额外键顺序(list)
RdictIO: I(nsertion) O(rder): keeps track of the order new keys where added
RdictFO, RdictFO2: F(ix) O(rder): keeps track of the order of the keys when it was created/initialized
- all three have the extra_key_order (list):
- this is a list which can be optionally set with a user defined key order (can also include just a subset of keys)
all three can be converted to OrderedDict: keeping their key_order or optionally the extra_key_order
- example usage to print an ordered json using the method: tojson_keeporder()
example_rdictordered=RdictFO([('key1','value1'),('key2','value2'),('key3',RdictIO([('inner_key1','innervalue1'),('inner_key2','innervalue2'),],False)),],False)json_dumps=example_rdictordered.tojson_keeporder(indent=3)print(json_dumps)
Output will be:
{"key1":"value1","key2":"value2","key3":{"inner_key1":"innervalue1","inner_key2":"innervalue2"}}
RdictFO与RdictFO2:RdictFO可以更改值rdictfo2在创建后不能更改值
Edict类似于普通的python dict,但具有一些附加(扩展)功能
Rdict和RdictIO:可以在创建/初始化后添加新项
RdictF和RdictFO,RdictFO2:F(ix)无法在创建/初始化后添加新项
rdict和rdictf:没有任何键顺序(list)或任何额外键顺序(list)
rdictio和rdictfo,rdictfo2:o(o rder)有一个键顺序(list)加上一个额外键顺序(list)
RdictIO: I(nsertion) O(rder): keeps track of the order new keys where added
RdictFO, RdictFO2: F(ix) O(rder): keeps track of the order of the keys when it was created/initialized
- all three have the extra_key_order (list):
- this is a list which can be optionally set with a user defined key order (can also include just a subset of keys)
all three can be converted to OrderedDict: keeping their key_order or optionally the extra_key_order
- example usage to print an ordered json using the method: tojson_keeporder()
example_rdictordered=RdictFO([('key1','value1'),('key2','value2'),('key3',RdictIO([('inner_key1','innervalue1'),('inner_key2','innervalue2'),],False)),],False)json_dumps=example_rdictordered.tojson_keeporder(indent=3)print(json_dumps)Output will be:
{"key1":"value1","key2":"value2","key3":{"inner_key1":"innervalue1","inner_key2":"innervalue2"}}RdictFO与RdictFO2:RdictFO可以更改值rdictfo2在创建后不能更改值
ReLIST
- elist类似于普通的python列表,但具有一些附加(扩展)功能
- rlist:可以在创建/初始化之后添加新项
- rlistf:f(ix)无法在创建/初始化后添加新项
ReTUPLE
- etuple类似于普通的python元组,但有一些附加(扩展)功能
^{a16号}
- lmatrix是具有一些附加(扩展)功能的元组列表
- lmatrixf:f(ix)无法在创建/初始化后添加新项(元组行)
Code Examples
有关代码示例,请参阅“development source”文件夹中的文件:examples、Tests、SpeedCheck
Projects using ReOBJ
利用:ReOBJ的项目
ReOBJ根据BSD 3条款许可的条款分发。 咨询license.rst或http://opensource.org/licenses/BSD-3-Clause。
(c)2014年,peter1000https://github.com/peter1000 保留所有权利