Skip to main content

一个关于Python对象工具的模块。A tool of python object with tkinter and command-lines.

Project description

pyobject - 一个关于Python对象工具的模块。A tool of python object with tkinter and command-lines.

Build passing 100% test coverage

所包含模块 Included modules:

__init__ - 打印出Python对象的各个属性

pyobject.browser - 以图形方式浏览Python对象

pyobject.code_ - Python bytecode的操作工具

pyobject.search - 搜索python对象

pyobject.newtypes - 定义一些新的类型

包含的函数 Functions:

objectname(obj):

objectname(obj) - 返回一个对象的名称,形如xxmodule.xxclass。
如:objectname(int) -> 'builtins.int'

bases(obj, level=0, tab=4):

bases(obj) - 打印出该对象的基类
tab:缩进的空格数,默认为4。

describe(obj, level=0, maxlevel=1, tab=4, verbose=False, file=sys.stdout, mode=’w’ encoding=’utf-8’):

"描述"一个对象,即打印出对象的各个属性。
参数说明:
maxlevel:打印对象属性的层数。
tab:缩进的空格数,默认为4。
verbose:一个布尔值,是否打印出对象的特殊方法(如__init__)。
file:一个类似文件的对象。

browse(object, verbose=False, name=’obj’):

以图形方式浏览一个Python对象。
verbose:与describe相同,是否打印出对象的特殊方法(如__init__)

新增函数 New Functions:

make_list(start_obj, recursions=2, all=False):

创建一个对象的列表。
start:开始搜索的对象
recursion:递归次数
all:是否将对象的特殊属性(如__init__)加入列表

类似:make_iter

search(obj, start, recursions=3):

从一个起点开始搜索对象
obj:待搜索的对象
start:起点对象
recursion:递归次数

新增类: pyobject.newtypes.Code 用法: (下面的示例是从doctest中摘取的):

>>> def f():print("Hello")
>>> c=Code.fromfunc(f)
>>> c.co_consts
(None, 'Hello')
>>> c.co_consts=(None, 'Hello World!')
>>> c.exec()
Hello World!
>>>
>>> import os,pickle
>>> temp=os.getenv('temp')
>>> with open(os.path.join(temp,"temp.pkl"),'wb') as f:
...     pickle.dump(c,f)
...
>>> f=open(os.path.join(temp,"temp.pkl"),'rb')
>>> pickle.load(f).to_func()()
Hello World!
>>>
>>> c.to_pycfile(os.path.join(temp,"temppyc.pyc"))
>>> sys.path.append(temp)
>>> import temppyc
Hello World!
>>> Code.from_pycfile(os.path.join(temp,"temppyc.pyc")).exec()
Hello World!

版本:1.1.4

改进:修复了一些bug,pyobject.code_中增加了Code类,browser中增加编辑属性功能, 增加了Code类的测试。

作者 Author: 七分诚意 qq:3076711200 邮箱:3416445406@qq.com

作者主页: <https://blog.csdn.net/qfcy_/>`_

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyobject--1.1.4.tar.gz (10.2 kB view details)

Uploaded Source

File details

Details for the file pyobject--1.1.4.tar.gz.

File metadata

  • Download URL: pyobject--1.1.4.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.25.1 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.2rc1

File hashes

Hashes for pyobject--1.1.4.tar.gz
Algorithm Hash digest
SHA256 1939abbda2e361e231a21765bf5af376c2cecc0815141048cba1bd115be0ff6a
MD5 295082b47c9ce761431c73c272407c5b
BLAKE2b-256 2c8d706dfcd0a2a26947f2e8ebcb58d0c1f2c83a124cb5085f21b386de314f13

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page