一个最小但固执己见的dict/对象组合(比如bunch)。

ctx的Python项目详细描述


CTX-一个最小但固执己见的dict/对象组合(类似bunch)。

https://travis-ci.org/figlief/ctx.png?branch=master

要求

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”]”使用以下三个步骤进行解析。

  1. 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.

  1. raise LookupError.

'ctx.name=5'和'ctx[“name”]=5'

  1. If name is an attribute of the class then raise AttributeError.
  2. set the dictionary item as usual.

安装

您可以使用pip和以下命令安装这个包。

pip install ctx

支架

要报告任何错误或提出任何问题,请访问

https://github.com/figlief/ctx/issues.

资源

以下是有关此项目的有用链接列表。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java与Groovy正则表达式匹配混淆   java控制台未定义为JSNI   主目录中的java指针异常   java如何获取hashmap中的arrayList的大小   ApachePOI用于文本,Java代码中的word doc(.docx)中没有进行追加   Ruby对象到Java对象   JavaSpringJPA哈希集只返回一个值   Java在执行由配置了精确类路径参数的mavenjarpluin生成的可执行jar时无法找到依赖项   java我试图在画布上写一个文本,但什么也没发生   java HTTP 404源服务器找不到目标资源的当前表示形式,或者不愿意透露存在该表示形式。不起作用   java提取小数点后的最后一个数字   oop Java:无法访问对象的元素   PHP URL中RecyclerView中的java句柄空异常   不调用OnCreateViewHolder的java Update RecyclerView适配器项