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

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 NIO选择器最多只能选择50个SelectionKeys?   java阻止ImageButton创建新活动   为什么Java方法“Arrays.copyOf”处理中的整数数组与处理对象数组时的行为不同   java将安卓 1.6日历字段提取到vcal   将字符串转换为双精度后的java问题   java使用Webflux,是否可以使用AOP获取用于日志记录的ServerHttpRequest   java与jTextArea的基本区别是什么。setText()和jTextArea。append()方法?   java程序执行时间|将值保存到文件或数据结构?   java如何将表示字符的整数转换为字符串?   Java LWJGL新的渲染问题windows   java GUI提供异常   java创建第二个对象使类的函数不再工作   如何在java中将000验证为3位数字?   java bigO算法的时间复杂度,可以在不重复的情况下找到最长的子串   在30像素内点击按钮后,java在两个图像之间转换   java eclipse maven nexus不可解父pom   当存在其他SecurityConstraint时,java TransportGuary机密将被忽略   重新连接后激发的java Red5客户端流断开事件   javafx聊天应用程序中连接客户端的java问题