Simple, small, interactive, console-based debugger.
KRT inherits from basic python debugger (called bdb). The main reason behind development of package was need of user interface during python script debugging in console (or when graphical interface is not available). Although pdb have the same (and propbably much more) functionality, I found it not so “user friendly”.
Install using pip.
pip install krt
python krt.py script.py # or python -m krt script.py
This method of initialization allows initialization at specific line.
import krt def func(_something, _nothing): local_var = [1, 2, 3, 4] # now, initialize krt krt.trace() anything = _somethins + _nothing return anything
Initializing krt via decorator. This method will initialize krt at 1st line of decorated method or function.
import krt # initialize krt @krt.debug() def func(_something, _nothing): local_var = [1, 2, 3, 4] anything = _somethins + _nothing return anything
One can use methods mentioned above, but method below allows krt triggering only if run with pre-defined django command.
class Command(runserver.Command): help = “Sets trigger for krt decorators” def __init__(self, *args, **kwargs): from django.conf import settings setattr(settings, 'krt_django_decorator_trigger_flag', True) super(Command, self).__init__(*args, **kwargs)
Decorator, when used in django project, requires setting of keyword argument django to True. If the django argument is omitted, the debugger will be always initialized!
from django.http import HttpResponse from krttest.krt import debug @debug(django=True) def index(request): return HttpResponse("I'm ok.")
Now, when the django server is run with created command, KRT debugger is being initialized on 1st line of view, otherwise the decorators are being ignored.
python ./manage.py krt_runserver