Skip to main content

Useful tools for debugging Python code

Project description

lets-debug

Build Status

Introduction

This package allows you to debug your Python code using terminal tools.

Installation

pip install lets-debug

Imports

from lets_debug import terminal, DecoratorTools

Reference

terminal

These are the available methods from terminal:

log(*args)

Prints every element passed in *args using blue color.

warn(*args)

Prints every element passed in *args using orange color.

error(*args)

Prints every element passed in *args using red color.

success(*args)

Prints every element passed in *args using green color.

clear()

Clear terminal or command prompt screen.

count(name='counter')

Counts number of times that name was called using this method. It is useful for couting number of times that a function is called. See the example bellow:

def greet():
    terminal.log('Welcome!')
    terminal.count('greet')

greet()
greet()

The output will be:

greet: 1
greet: 2

check_bool(boolean: bool, callback: Any)

Prints callback if boolean is False.

table(dictionary_list: List[Dict])

Prints dictionary_list as table.

DecoratorTools

These are the available methods from DecoratorTools class (all methods are static):

log(*args, type='log')

Prints every element passed in *args using custom color. type argument defines the color. The available types are 'log', 'warn', 'error', and 'success'.

count(*args)

Counts number of times that a function was called.

stopwatch(*args)

Counts how long a function takes to run.

override(*args, **kwargs)

Check if the current method exists in its parent object. See the example bellow:

class Human:

    def walk(self):
        terminal.log('Human is walking...')

class Person(Human):

    @override
    def walk(self):
        terminal.log('Person is walking...')

This code is OK. But if you remove walk() from Human class, an error message will appear in the output.

If you want the program to stop in this situations, set get_error option to True:

@override(get_error=True)
def walk(self):

Contributions

Feel free to use this package and to contribute on this repository with your ideas!

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

lets_debug-0.0.4-py3-none-any.whl (6.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page