Python交互式游乐场
项目描述
关于
pyplay 是一个命令行工具,它调用交互式Python shell,但启动时启用制表符完成,将常用路径添加到 sys.path,预加载常用模块,并可选择运行一些启动Python命令。
它是可配置的,可以在系统范围级别和每个项目(目录)级别进行配置。
安装
从源安装
sudo python setup.py install
使用方法
要启动一个 pyplay shell,只需输入类似以下命令
pyplay # Start Python and handy modules pyplay --none # No extras pyplay -re yaml # All except re, then add yaml pyplay --none yaml # Nothing except yaml pyplay xyz test_foo # import xyz and test_foo
配置
如果您经常使用 pyplay 并始终想预加载相同的模块,您可以在名为 ~/.pyplay/config.yaml 或 ./pyplay/config.yaml 的文件中设置自己的自定义配置,如下所示
# Is readline & tab completion on? readline: true # Added to the front of sys.path. pythonpath: - . - lib - tests # Modules to import by default. modules: - os - sys - yaml # Commands to run by default - from yaml import *
如果您显式地提供了 PYPLAY_CONFIG_DIR 环境变量,那么将使用该目录来查找 config.yaml 文件。如果您将 PYPLAY_CONFIG_DIR 设置为空字符串,则不会读取任何配置文件,即使其中一个存在。
此外,如果它们存在,PYPLAY_CONFIG_DIR、~/.pyplay/ 和 ./pyplay/ 将被添加到 sys.path 的前面,因此您可以将要在此处使用的模块放入这些目录中。
命令行选项
- --none
清除要导入的模块列表
- module
将模块添加到导入列表
- -module
从导入列表中删除模块
示例运行
以下是启动会话时的样子
$ pyplay foo bar Python 2.6.2 (r262:71600, Apr 16 2009, 09:17:39) [GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin Type "help", "copyright", "credits" or "license" for more information. *** Welcome to PyPlay version 0.3 -- Type h() for help. *** PyPlay tab completion enabled >>> import os >>> import sys >>> import re >>> import foo >>> import bar >>>
PyPlay 命令
Pyplay 添加了一些额外的 shell 命令。当前的命令有
- h()
显示 PyPlay 帮助屏幕。
- y(object)
打印任何对象的 YAML 格式输出。(需要 yaml 模块)
待办事项
在未来的版本中,您可能会看到
记录 shell 命令
在会话之间保存 readline 历史记录
更多 PyPlay 特殊命令
项目详情
关闭
pyplay-1.0.5.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 00753628e0d78d59cb63d32fae59dfa14541867a8bccc0b8cab4c03b74287cb8 |
|
MD5 | 2d7f08ae3b0c05581c0318ab670347d5 |
|
BLAKE2b-256 | 3441521e6b5673d2bed6aa8dfea8cd9501be6cad77f14fda1282640154699cc4 |