https://github.com/trsqxyz/prins
Usage
>>> import prins
>>> p = prins.prins()
>>> p.dropto('this', 'prins', 'spam')
Not Found spam.
I found that ʻimp.find_module () opens the source file with read, so I wanted to know it and wanted to write it to a text file at once. Arguments that are not passed as a character string are converted to a character string, but if ʻimport
is done, they will not be searched properly.
I think it will be useful when you know the standard module
Prins stands for Print source
I received a comment.
When searching for a standard module, you may start a pydoc server with pydoc -p 8080.
I was able to browse the Python 3.x documentation with pydoc -p 8080
and then b
with Python 2.x pydoc3 -p 8080
. Very convenient
Also, if you want to know information about modules like this article, the inspect package is useful. For example
import re
import inspect
print(inspect.getsourcefile(re)) #Get file path
print("".join(inspect.findsource(re)[0])) #Get the contents of the file
I thought this method would be smart when checking at a terminal.
However, there were ʻinspect.filesource () and ʻinspect.getsource ()
, so I examined the difference.
>>> import re
>>> import inspect
>>> type(inspect.getsource(re))
<class 'str'>
>>> type(inspect.findsource(re))
<class 'tuple'>
So you can also check it with print (inspect.getsource (re))
.
@podhmo Thank you.
Recommended Posts