与语句相关的黑客的构建块

withhacks的Python项目详细描述


WithHacks:与语句相关的Hackry的构建块

这个模块是一个有用的构建块的集合,用于破解python “with”语句。它结合了几个简洁的想法和语句技巧 我在网上找到了一套可重复使用的组件:

通过从这个模块子类化适当的上下文管理器,您可以 轻松完成以下操作:

  • skip execution of the code inside the with-statement
  • set local variables in the frame executing the with-statement
  • capture the bytecode from inside the with-statement
  • capture local variables defined inside the with-statement

在这些基本工具的基础上,本模块还提供了一些有用的预构建 黑客:

xargs:call a function with additional arguments defined in the body of the with-statement
xkwargs:call a function with additional keyword arguments defined in the body of the with-statement
namespace:direct all variable accesses and assignments to the attributes of a given object (like “with” in JavaScript or VB)
keyspace:direct all variable accesses and assignments to the keys of of a given object (like namespace() but for dicts)

WithHacks广泛使用了Noam Raphael的神奇“Byteplay”模块; 因为官方的byteplay发行版不支持Python2.6,所以 此模块中包含带有适当修补程序的版本。

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

推荐PyPI第三方库


热门话题
反射Java反射:高负载下的NoSuchMethodException   java RxJava:one request>list of Integer>sequence of requests for each int>result to list   java为什么循环之前索引会增加   JavaSpring远程处理和RESTfulURL   java Hibernate搜索仅对我的实体的一部分进行索引   使用DPAD快速滚动时,java RecyclerView onCreateViewHolder调用过多   java将JSON解析到一个表中   java导航抽屉标题textview nullpointerexception   基于接口的Java链接队列   java Guice运行时依赖项参数重新注入   java展平/压缩ZSH中的深度嵌套目录   JavaSpring:Http406此请求标识的资源只能   java如何制作Android启动器图标   Java代码在windows上显示不正确(包含希腊语句子)   使用yourkit进行内存分析所用的java时间   java为什么可以序列化属性而不能序列化对象本身?