Giter Club home page Giter Club logo

pydiary's Introduction

pydiary

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

Usage

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 diary.off() to disable logging.

from pydiary import Diary

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

...

# The current active diary is automatically assigned to a variable called "diary"
diary.off()             # 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 mydiary.py in the current directory
my_diary = Diary('mydiary.py')      # You can save a reference to the Diary instance to use it later

...

my_diary.off()

...

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.

Diary(buffered=False)

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 diary.off() to see them in the file.

Improvement, Issues report

Suggest improvements or features, report bugs at https://github.com/nathanlepori/pydiary/issues

Authors

  • Nathan Lepori

pydiary's People

Contributors

nathanlepori avatar

pydiary's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.