I am working on Ipython like to get help info about
os.stat and redirect the output to a plain markdown file:
In : with contextlib.redirect_stdout(open("stat_help_docs.md", "w")): ...: help(os.stat) ...: In : os.stat("stat_help_docs.md").st_size Out: 1
The "stat_help_docs.md" is empty, it failed to write help docs to it.
However, If I tried in the Standard Python Interactive Mode:
>>> import os >>> import contextlib >>> with contextlib.redirect_stdout(open("another_stat_help_docs.md", "w")): ... help(os.stat) ... >>> os.stat("another_stat_help_docs.md").st_size 919
It succeeded in write to the file.
I assume the problem might lie in the setting of Ipython,
Could please provide any hints to help dig in the problem?