I was wondering if there is any way we can read doc strings present in a python file from command line, prior to importing it, or w/o using any Ipython or Python kernel, just like 'man' command does.
-
Since Python comes with this functionality built-in, why would you want to use another tool for this? Any other tool would be duplicating this functionality & so why would it be worthwhile installing another tool vs just using Python?Gerrat– Gerrat2017-08-05 14:19:04 +00:00Commented Aug 5, 2017 at 14:19
-
But Python requires you to manually import file, then only we can read it. If there is any work around which does not require you to fire python shell?Adarsh Maurya– Adarsh Maurya2017-08-05 14:31:22 +00:00Commented Aug 5, 2017 at 14:31
Add a comment
|
1 Answer
You can execute some python code from the command line, so given a module named my_module.py, and a function named my_function, the following:
python -c "from my_module import my_function;print my_function.__doc__"
will print out the docstring