Top Related Projects
pdb++, a drop-in replacement for pdb (the Python debugger)
An implementation of the Debug Adapter Protocol for Python
Never use print for debugging again
Integration of IPython pdb
Parsing ELF and DWARF in Python
Quick Overview
PuDB is a full-screen, console-based visual debugger for Python. It aims to provide all the features of GUI-based debuggers in a more lightweight and keyboard-friendly package. PuDB allows developers to debug their Python code with an intuitive, text-based interface directly in the terminal.
Pros
- Full-screen, console-based interface that works well over SSH and in environments without GUI support
- Intuitive, easy-to-use interface with syntax highlighting and variable inspection
- Keyboard-friendly navigation and commands for efficient debugging
- Customizable appearance and behavior to suit individual preferences
Cons
- Limited graphical capabilities compared to GUI-based debuggers
- May have a steeper learning curve for users accustomed to traditional GUI debuggers
- Not as feature-rich as some more comprehensive debugging tools
- Performance may be slower for very large codebases or complex debugging scenarios
Code Examples
- Basic usage with a breakpoint:
from pudb import set_trace
def example_function():
x = 5
y = 10
set_trace() # Debugger will pause here
result = x + y
return result
example_function()
- Using PuDB as a post-mortem debugger:
import pudb
def divide(a, b):
return a / b
try:
result = divide(10, 0)
except ZeroDivisionError:
pudb.post_mortem()
- Conditional breakpoint:
from pudb import set_trace
for i in range(100):
if i == 50:
set_trace() # Debugger will pause when i equals 50
print(i)
Getting Started
To get started with PuDB, follow these steps:
-
Install PuDB using pip:
pip install pudb
-
In your Python code, import and use PuDB:
from pudb import set_trace def your_function(): # Your code here set_trace() # Add this where you want to pause execution # More code your_function()
-
Run your script as usual. When the
set_trace()
line is reached, the PuDB interface will appear in your console. -
Use the keyboard to navigate and control the debugger. Press '?' in the PuDB interface to view available commands and shortcuts.
Competitor Comparisons
pdb++, a drop-in replacement for pdb (the Python debugger)
Pros of pdbpp
- Lightweight and easy to integrate into existing workflows
- Extensive customization options through configuration files
- Better support for multi-line expressions and syntax highlighting
Cons of pdbpp
- Less intuitive user interface compared to PuDB's curses-based UI
- Lacks some advanced features like variable watching and stack viewer
- May require more manual configuration for optimal usage
Code Comparison
PuDB:
from pudb import set_trace
set_trace()
# Your code here
pdbpp:
import pdb
pdb.set_trace()
# Your code here
Key Differences
PuDB offers a full-screen, curses-based interface with a visual representation of the source code, variables, and stack. It's more user-friendly for beginners and provides a GUI-like experience in the terminal.
pdbpp, on the other hand, enhances the standard Python debugger (pdb) with features like syntax highlighting, tab completion, and sticky mode. It's more lightweight and closer to the traditional debugging experience.
Both debuggers have their strengths, with PuDB excelling in ease of use and visual feedback, while pdbpp offers more flexibility and integration with existing debugging practices.
An implementation of the Debug Adapter Protocol for Python
Pros of debugpy
- Designed for remote debugging and integration with IDEs like VS Code
- Supports debugging of multi-threaded and multi-process applications
- Offers a rich API for customizing debug sessions
Cons of debugpy
- Steeper learning curve for beginners compared to PuDB's text-based interface
- Requires an IDE or separate client for full functionality
- May have higher overhead for simple debugging tasks
Code Comparison
PuDB (text-based interface):
import pudb
pudb.set_trace()
# Your code to debug
debugpy (used with VS Code):
import debugpy
debugpy.listen(5678)
debugpy.wait_for_client()
# Your code to debug
Summary
PuDB is a lightweight, console-based debugger ideal for quick debugging sessions and remote server environments. debugpy, on the other hand, is more powerful and flexible, designed for integration with modern IDEs and remote debugging scenarios. While PuDB offers simplicity and ease of use, debugpy provides advanced features for complex debugging tasks at the cost of a steeper learning curve.
Never use print for debugging again
Pros of PySnooper
- Lightweight and easy to use with minimal setup
- Generates detailed logs of variable changes and function calls
- Can be used as a decorator or context manager for flexibility
Cons of PySnooper
- Limited interactive debugging capabilities
- No built-in GUI or visual interface
- May generate large log files for complex programs
Code Comparison
PySnooper:
import pysnooper
@pysnooper.snoop()
def calculate_factorial(n):
if n == 0:
return 1
return n * calculate_factorial(n - 1)
PuDB:
import pudb
pudb.set_trace()
def calculate_factorial(n):
if n == 0:
return 1
return n * calculate_factorial(n - 1)
Key Differences
- PuDB offers an interactive, console-based debugger with a visual interface
- PySnooper focuses on generating detailed logs for post-execution analysis
- PuDB provides real-time debugging with breakpoints and step-through functionality
- PySnooper is more suitable for quick debugging and logging in production environments
- PuDB offers a more comprehensive debugging experience similar to IDEs
Both tools have their strengths, with PySnooper excelling in simplicity and logging, while PuDB provides a more feature-rich interactive debugging experience.
Integration of IPython pdb
Pros of ipdb
- Integrates seamlessly with IPython, providing access to its powerful features
- Lightweight and easy to install with minimal dependencies
- Familiar interface for users already comfortable with pdb
Cons of ipdb
- Less feature-rich compared to pudb's text-based GUI
- Limited visual representation of program state
- May be less intuitive for beginners compared to pudb's interface
Code Comparison
ipdb:
import ipdb
ipdb.set_trace()
pudb:
import pudb
pudb.set_trace()
Both debuggers use similar syntax for setting breakpoints, but pudb offers a more comprehensive visual interface for debugging, while ipdb provides a more streamlined, IPython-based experience. pudb excels in presenting a clear overview of the program state, variables, and call stack, making it particularly useful for complex debugging scenarios. ipdb, on the other hand, leverages the power of IPython for a more interactive and familiar debugging experience for those already comfortable with IPython or pdb.
Parsing ELF and DWARF in Python
Pros of pyelftools
- Specialized for parsing and analyzing ELF files
- Comprehensive documentation and examples
- Actively maintained with regular updates
Cons of pyelftools
- Limited to ELF file analysis, not a general-purpose debugger
- Steeper learning curve for users unfamiliar with ELF file structures
- Command-line interface only, no graphical user interface
Code Comparison
pyelftools:
from elftools.elf.elffile import ELFFile
with open('example.elf', 'rb') as f:
elf = ELFFile(f)
for section in elf.iter_sections():
print(section.name)
pudb:
import pudb
def main():
x = 5
y = 10
pudb.set_trace()
result = x + y
print(result)
main()
pyelftools focuses on ELF file analysis, providing tools to parse and extract information from ELF files. pudb, on the other hand, is a full-featured debugger with a text-based user interface, allowing for interactive debugging of Python code. While pyelftools is specialized for ELF files, pudb offers a more general-purpose debugging experience for Python developers.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
PuDB: a console-based visual debugger for Python
.. image:: https://gitlab.tiker.net/inducer/pudb/badges/main/pipeline.svg :alt: Gitlab Build Status :target: https://gitlab.tiker.net/inducer/pudb/commits/main .. image:: https://github.com/inducer/pudb/actions/workflows/ci.yml/badge.svg :alt: Github Build Status :target: https://github.com/inducer/pudb/actions/workflows/ci.yml .. image:: https://badge.fury.io/py/pudb.png :alt: Python Package Index Release Page :target: https://pypi.org/project/pudb/
Its goal is to provide all the niceties of modern GUI-based debuggers in a more lightweight and keyboard-friendly package. PuDB allows you to debug code right where you write and test it--in a terminal.
Here are some screenshots:
-
Light theme
.. image:: doc/images/pudb-screenshot-light.png
-
Dark theme
.. image:: doc/images/pudb-screenshot-dark.png
You may watch screencasts too:
-
Meet Pudb, a debugger for Python code (2020) <https://www.youtube.com/watch?v=bJYkCWPs_UU>
_ -
PuDB Intro Screencast (2009) <http://vimeo.com/5255125>
_
Features
-
Syntax-highlighted source, the stack, breakpoints and variables are all visible at once and continuously updated. This helps you be more aware of what's going on in your program. Variable displays can be expanded, collapsed and have various customization options.
-
Pre-bundled themes, including dark themes via "Ctrl-P". Could set a custom theme also.
-
Simple, keyboard-based navigation using single keystrokes makes debugging quick and easy. PuDB understands cursor-keys and Vi shortcuts for navigation. Other keys are inspired by the corresponding pdb commands.
-
Use search to find relevant source code, or use "m" to invoke the module browser that shows loaded modules, lets you load new ones and reload existing ones.
-
Breakpoints can be set just by pointing at a source line and hitting "b" and then edited visually in the breakpoints window. Or hit "t" to run to the line under the cursor.
-
Drop to a Python shell in the current environment by pressing "!". Or open a command prompt alongside the source-code via "Ctrl-X".
-
PuDB places special emphasis on exception handling. A post-mortem mode makes it easy to retrace a crashing program's last steps.
-
Ability to control the debugger from a separate terminal.
-
IPython integration (see
wiki <http://wiki.tiker.net/PuDB>
_) -
Should work with Python 3.6 and newer. (Versions 2019.2 and older continue to support Python 2.7.)
Links
PuDB documentation <https://documen.tician.de/pudb>
_
PuDB also has a mailing list <http://lists.tiker.net/listinfo/pudb>
_ that
you may use to submit patches and requests for help. You can also send a pull
request to the GitHub repository <https://github.com/inducer/pudb>
_
Development Version
You may obtain the development version using the Git <http://git-scm.org/>
_
version control tool.::
git clone https://github.com/inducer/pudb.git
You may also browse the code <https://github.com/inducer/pudb>
_ online.
Top Related Projects
pdb++, a drop-in replacement for pdb (the Python debugger)
An implementation of the Debug Adapter Protocol for Python
Never use print for debugging again
Integration of IPython pdb
Parsing ELF and DWARF in Python
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot