Created
October 8, 2014 07:50
-
-
Save archerslaw/cf99c5285a3f52aa96e8 to your computer and use it in GitHub Desktop.
a userfull modules(inspect) for python users.
This file contains hidden or 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
###inspect - Get useful information from live Python objects. | |
This module can gives you the source code from the function name. It has several different functions which is very useful when you debug. Please check the details with help(). | |
Example: | |
>>> import inspect | |
>>> import re | |
>>> a = inspect.getsource(re.split) | |
>>> print a | |
def split(pattern, string, maxsplit=0): | |
"""Split the source string by the occurrences of the pattern, | |
returning a list containing the resulting substrings.""" | |
return _compile(pattern, 0).split(string, maxsplit) | |
>>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment