Skip to content

Instantly share code, notes, and snippets.

@rlabbe
Created November 3, 2016 16:15
Show Gist options
  • Save rlabbe/866da87194253de5f3bab817467a8879 to your computer and use it in GitHub Desktop.
Save rlabbe/866da87194253de5f3bab817467a8879 to your computer and use it in GitHub Desktop.
Print source without docstring
from inspect import getsource
import re
def psource(fun):
print(re.sub('""".*"""', '', getsource(fun), flags=re.DOTALL))
#example
from somewhere import foo
psource(foo)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment