蟒蛇互动游乐场
pypla的Python项目详细描述
关于
pyplay是调用交互式python的命令行工具 shell,但在打开tab completion、公共路径时启动 添加到sys.path,预加载了公共模块,还可以选择一些 启动python命令运行。
它是可配置的,无论是在系统级还是在每个项目上 (目录)级别。
安装
从源安装:
sudo python setup.py install
用法
要启动pyplayshell,只需输入如下命令:
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/将是 如果它们存在,则添加到^ {Tt2}$的前面,这样就可以放置模块。 你想在那些目录里玩的。
命令行选项
- --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(对象)
- 打印任何对象的yaml转储。(需要yaml模块)
待办事项
在以后的版本中,您可能会看到:
- shell命令的日志记录
- 保存会话之间的readline历史记录
- 更多pyplay特殊命令