Created
February 24, 2017 18:21
-
-
Save meetmangukiya/4aee7c4b51b205e9badbe30ba3ef8db9 to your computer and use it in GitHub Desktop.
List functions and methods of classes in a python file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ast | |
import sys | |
import os | |
with open(os.path.abspath(sys.argv[-1])) as f: | |
fc = f.read() | |
for i in filter(lambda x: isinstance(x, ast.FunctionDef), ast.parse(fc).body): | |
print(i.name) | |
print("\n\n") | |
for i in filter(lambda x: isinstance(x, ast.ClassDef), ast.parse(fc).body): | |
print(i.name) | |
for j in filter(lambda x: isinstance(x, ast.FunctionDef), i.body): | |
print(" " + j.name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment