跳转到主要内容

打印当前文件和行号

项目描述

There

打印当前文件名和行。

例如,where.py

import there
import there as here

print(here)
print('and')
print(there)

然后 python where.py 将打印

where.py:4
and
where.py:6

替换print函数

There 提供了替换 print 函数的解决方案,该函数会在前面添加文件名和行号。

例如,where.py

from there import print

print('hi')
print('there')

然后 python where.py 将打印

where.py:3 hi
where.py:4 there

就是这样

就是这样(目前),不多也不少。我有计划(通常永远不会实现)—— 要有一个 there.indent,它可以返回当前行的缩进。

注意事项

返回计算 __str____repr__there 的行。通常通过 print。所以它可能不正确。如果您想要确保(例如,使用 log),请将其包裹在 str() 中。

可能仅在CPython上运行。但无论如何,不要在生产环境中运行。

项目详情


下载文件

下载适用于您平台的文件。如果您不确定选择哪个,请了解有关 安装软件包 的更多信息。

源分布

there-0.0.12.tar.gz (43.1 kB 查看哈希)

上传时间:

构建分布

there-0.0.12-py2.py3-none-any.whl (3.2 kB 查看哈希值)

上传时间 Python 2 Python 3

由以下支持