Skip to main content

MatLab style commands logger for the Python interpreter

Project description


MatLab style commands logger for the Python interpreter, with added features.


Import the Diary class from the package and create a new instance. The commands you type in from now on will be logged into a file. Call to disable logging.

from pydiary import Diary

Diary()                 # Turns diary on, saving commands to the default file


# The current active diary is automatically assigned to a variable called "diary"             # Turns diary off

You can pass a custom path for the diary file and save the instance to re-enable it afterwards:

# Turns diary on, saving commands to a file called in the current directory
my_diary = Diary('')      # You can save a reference to the Diary instance to use it later



my_diary.on()           # Turns on the previously created diary

Advanced usage

Buffered mode

By default pydiary uses an internal string buffer to keep the diary file free for manual changes, and only writes to it when you turn off the diary. You can force pydiary to flush commands to the file by calling diary.flush().

Call diary.discard() if you want to discard all commands not yet written to the diary file.

Direct mode

You can force pydiary to operate in direct mode by setting the buffered parameter to False when creating an instance.


In this mode pydiary will write commands directly to the diary file. Note that due to the way Python handles writing to files, the commands may not be written immediately and you may still need to call to see them in the file.

Improvement, Issues report

Suggest improvements or features, report bugs at


  • Nathan Lepori

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pydiary, version 1.1.0
Filename, size File type Python version Upload date Hashes
Filename, size pydiary-1.1.0-py3-none-any.whl (4.8 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size pydiary-1.1.0.tar.gz (3.5 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page