显示在Python空闲会话的用户定义的函数列表 [英] Display a list of user defined functions in the Python IDLE session

查看:121
本文介绍了显示在Python空闲会话的用户定义的函数列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能在空闲会话以显示所有用户功能列表?

Is it possible to display a list of all user functions in the IDLE session?

我可以看到他们在自动完成雨​​后春笋般冒出来,也许还有其他的方式来仅仅只显示为会话定义的用户功能。当你忘记了函数的名称是非常有用的。而且当你要确保当一个会话关闭不丢失源$ C ​​$ C的作用。

I can see them popping up in the autocomplete, so maybe there is other way to just display only the user functions defined for the session. It is useful when you forget the name of the function. And also when you want to make sure that you don't lose source code for a function when a session is closed.

推荐答案

这应该给你的所有功能在全球范围内的列表:

This should give you a list of all functions in the global scope:

import types
print [f for f in globals().values() if type(f) == types.FunctionType]

这篇关于显示在Python空闲会话的用户定义的函数列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆