Skip to main content

Automatic pdb invoker

Project description

sweetdebug - Feel easy to debug


Automatic pdb invoker, Telegram support

Install

pip install sweetdebug

or (To use Telegram notification)

pip install sweetdebug[telegram]

Main Feature

  • Use the CLI command to debug any Python script without modifying the source:
sweetdebug your_script.py [script arguments...]
  • Or just add one(or two) line in your code:
from sweetdebug import sweetdebug
sweetdebug()
1/0 # Error !!
  • This will invoke pdb automatically.
Traceback (Most recent call last):
3 /main.py <module> --> 1/0
ZeroDivisionError: division by zero
> /main.py(3)<module>()
-> 1/0
(Pdb) 

Other feature(s)

  • You can receive error message with Telegram, too.
  • To get Telegram authentication token, See Telegram Botfather for details.
# Assume you have Telegram tokens and corresponding chat ids.

token = "123456789:ABCDEF_VGRXDZKwvHS8@Xca5e2EnZdfsgTw"
chat_ids = ["13852425", '29384594']
sweetdebug(telegram=True, telegram_api_token=token, chat_ids=chat_ids)


1/0 # Error !!
  • Also, If you have used your tokens and chat ids, then you can use cached token and chat ids.
sweetdebug(telegram=True)

img

Other feature(s) - 2 (Added from 1.0.8)

  • sweettimer : simple timer for a code snippets
from sweetdebug import sweettimer

# simple timer for a function
@sweettimer()
def xxx1():
    return sum([i for i in range(1000)])


# replace function name or time units
@sweettimer(name="my_xxx", unit="ms")
def xxx2():
    return sum([i for i in range(1000)])

# also supports context-level
with sweettimer():
    sum([i for i in range(1000)])

xxx1()
xxx2()

# you can also check elapsed times through this class attribute
print(sweettimer.times)
(/home/jongho/workspace/testbed/timer.py, line 15) :: elapsed 0.01293182373046875 s
(/home/jongho/workspace/testbed/timer.py)[xxx1] :: elapsed 2.288818359375e-05 s
(/home/jongho/workspace/testbed/timer.py)[my_xxx] :: elapsed 0.019788742065429688 ms
[(None, 0.011715888977050781, 's'), ('xxx1', 2.09808349609375e-05, 's'), ('my_xxx', 1.6927719116210938e-05, 'ms')]

Project details


Download files

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

Source Distribution

sweetdebug-1.1.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sweetdebug-1.1.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file sweetdebug-1.1.0.tar.gz.

File metadata

  • Download URL: sweetdebug-1.1.0.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for sweetdebug-1.1.0.tar.gz
Algorithm Hash digest
SHA256 6813e7e521f236574e210395f73f2d5c8ee94bf3554875fcc9641dd0c7bc9667
MD5 98b78db90a0c470c06f998bbd8e190d1
BLAKE2b-256 b712367e73f266cacec91513268e76b444121289fab45c6dce53db873ce3c22a

See more details on using hashes here.

File details

Details for the file sweetdebug-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: sweetdebug-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for sweetdebug-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2b68b5def108debc590aa58310b30d2f40d430229e3e099a2df6e2d95d26dd18
MD5 a22737ce31bfa02666492a9658180ee2
BLAKE2b-256 9c064248a821851c90d0f3cedb4506bc9aebd09b624be88fbbef4e3a22b77078

See more details on using hashes here.

Supported by

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