0

I'd like to "log" all of the text (python shell prompts, my commands, python shell output) that displays on my console window after I start the python shell.

I read about powershell's Tee-Object but after running python | tee -filename C:\Path\To\SessionLogfile.txt in powershell, the only text from the python session that were written out to SessionLogfile.txt were the outputs of my python commands.

For example, I was expecting to see this in SessionLogfile.txt:

Python 2.7.15 (v2.7.15:ca079a3ea3, Apr 30 2018, 16:30:26) [MSC v.1500 64 bit (AMD)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> print("Hello World")
>>> Hello World
quit()

And instead all I see is:

Hello World

It's not important that Tee-Object works. I'm just interested in capturing the session. It's helpful say, when I want to send out to a file the docstring when I issue the python command >>> help(someclass).

Minh Tran
  • 101
  • 2
  • I don't have the time to try it right now but I would try `Start-Transcript` – EBGreen Jul 09 '18 at 17:29
  • Related question on SO: [How to log everything that occurs in a Python interactive shell session?](https://stackoverflow.com/questions/8053900/how-to-log-everything-that-occurs-in-a-python-interactive-shell-session) – hoefling Jul 10 '18 at 18:02

0 Answers0