2

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.

2
  • 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? Commented 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? Commented Aug 5, 2017 at 14:31

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.