[Tutor] Python 3.5 console logging
Steven D'Aprano
steve at pearwood.info
Tue Dec 1 01:15:55 EST 2015
Hi Tyler, and welcome,
On Mon, Nov 30, 2015 at 04:50:35PM -0500, Tyler Smithers wrote:
> I am doing a project for my school and i am trying to find out how to make
> a event log. But every where i look all it has is just making a text
> document and it having in their what they put in their script. But i cant
> find out how to code python into recording everything that happens when i
> run the program. And can you please help me soon because i don't have much
> time. Thank you!
I'm not sure I understand what you want. Do you mean you want to use the
interactive interpreter, and every time you enter a line, that line gets
saved in a log file?
That's normally called "history", and Python 3.5 will have history
automatically turned on. If you hit the UP or DOWN arrows, the prompt
will go through the history, showing each line. Is that what you mean?
Otherwise, perhaps you could look at sys.__interactivehook__ and
sys.__displayhook__. I'm not sure how advanced you are with Python
programming, so if you need more help, please ask.
--
Steve
More information about the Tutor
mailing list