数据资源管理器
peepshow的Python项目详细描述
提供以下调试python应用程序的实用程序:
- show-将变量的名称和值打印到控制台的轻量级函数
- 窥视功能,数据检查的交互界面
安装
安装peepshow包:
pip install peepshow
peepshow使用clear,vim,man命令,这些命令在大多数linux发行版中都可用。其他操作系统的用户需要自己安装它们
内置
如果希望经常使用peepshow,请考虑将peep和show命令添加到Python的内置中编辑{site-packages}/sitecustomize.py或{user-site-packages}/usercustomize.py并附加以下内容:
importpeepshowimportbuiltinsbuiltins.peep=peepshow.peepbuiltins.show=peepshow.showbuiltins.peep_=peepshow.peep_builtins.show_=peepshow.show_
或者让安装程序为您执行此操作:
pip install peepshow --upgrade --force-reinstall --no-deps --install-option="--add-builtins"
请注意,pip uninstall peepshow命令不会撤消此更改你需要手动操作
断点
调用内置函数breakpoint()也可以调用peep()要启用这种行为,请使用PYTHONBREAKPOINT系统变量:
exportPYTHONBREAKPOINT=peepshow.peep
相容性
- 该软件预计能与Python3.6、3.7兼容。
- 它从未在Linux以外的操作系统中测试过。
- 在普通的python脚本、ipython或ptipython中启动时,它工作得很好
- 在诸如交互式python控制台的这些环境中,在pdb和ipdb中,peep和show不能推断用户上下文中变量的名称,因此需要明确地提供它们(例如,使用peep `和show_)。
用法
显示
运行此脚本:
x=123y={'name':'John','age':123}z="Hello World!"# show all the variables in the scopeshow()# or only variables of your choiceshow(x,y)# you can also rename themshow(my_var=x)# use 'show_' to specify variable names as a stringshow_('x')# expressions and renaming are also allowedshow_('x + 321',zet='z')
将产生以下输出:
x = 123 y = {'age': 123, 'name': 'John'} z = 'Hello World!' x = 123 y = {'age': 123, 'name': 'John'} my_var = 123 x = 123 x + 321 = 444 zet = 'Hello World!'
窥视
尝试运行以下脚本:
x=123y={'name':'John','age':123}z="Hello World!"# inspect dictionary that consists of all the variables in the scopepeep()# or inspect variable of your choice directlypeep(x)# use 'peep_' to specify variable name as a stringpeep_('x')
当交互界面弹出时:
- 按回车键查看可用变量列表
- 键入10,然后按回车键选择y
- 再次按回车键可查看词典中的条目
- 键入dir并按回车键列出y(不包括内置)的属性
- 键入continue并按enter继续,或键入quit并按enter终止脚本
请注意,所有命令都有其短别名例如,quit和q是相同的。
有关更多帮助:
- 键入help,然后按回车键查看可用命令的列表
- 键入man并按回车键阅读手册,完成后按q。
开发
准备环境
./setup.sh
source venv/bin/activate
修改依赖项
# edit setup.py # edit requirements*.in pip-compile pip-sync # git add... commit... push...
测试
pytest
释放
# update version in setup.py python setup.py sdist twine upload dist/peepshow-$VERSION.tar.gz git tag $VERSION git push --tags