一个最小但固执己见的dict/对象组合(比如bunch)。
ctx的Python项目详细描述
CTX-一个最小但固执己见的dict/对象组合(类似bunch)。
要求
ctx模块应该与python的所有版本一起工作。
功能
ctx模块提供了ctx类,它是 python“dict”对象。
Ctx modifies ‘dict’ in the following ways:
1 The dictionary items can be read or set using attribute access notation.
‘ctx.a’ is identical to ‘ctx[“a”]’ and ‘ctx.a = 5’ is identical to ‘ctx[“a”] = 5’2可以使用项访问符号读取对象属性。
‘ctx[“__doc__”]’ is identical to ‘ctx.__doc__’3在任何情况下都不能设置对象属性。
4字典不能有与 对象属性。
“ctx.name”和“ctx[“name”]”使用以下三个步骤进行解析。
- if the object has an attribute ‘name’ then return the attribute.
b) if the dictionary has a key ‘name’ then return the value associated with the key.
- raise LookupError.
'ctx.name=5'和'ctx[“name”]=5'
- If name is an attribute of the class then raise AttributeError.
- set the dictionary item as usual.
安装
您可以使用pip和以下命令安装这个包。
pip install ctx
支架
要报告任何错误或提出任何问题,请访问
https://github.com/figlief/ctx/issues.
资源
以下是有关此项目的有用链接列表。
- Latest release on PyPI
- Source code on GitHub
- Issue tracker on GitHub
- github上的更改日志 <;https://github.com/figlief/ctx/blob/master/history.rst>;