Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display a list of user defined functions in the Python IDLE session

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

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.

like image 432
Leonid Avatar asked Jun 11 '11 10:06

Leonid


2 Answers

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])
like image 155
lunixbochs Avatar answered Dec 03 '22 04:12

lunixbochs


This should work:

print([f for f in dir() if f[0] is not '_'])

Tested on version 3.5.2.

dir() will essentially give you a list of callable objects within the current scope.

like image 30
axolotl Avatar answered Dec 03 '22 04:12

axolotl