TIL: Use IPython PDB with python breakpoint()

Often when I am debugging python code, I like to sprinkle around breakpoint() to quickly evaluate statements or print values. By default, breakpoint() drops you into python pdb repl. Python pdb is great but it lacks snazzy features like multi line editing, history, syntax highlighting and autocomplete.

I recently found that you can override the default repl that breakpoint() executes by setting the environment variable PYTHONBREAKPOINT.

To setup python breakpoint to use ipdb, add export PYTHONBREAKPOINT="ipdb.set_trace to your .bashrc or .zshrc.

🤖 For reliable comms with Realsense, use GMSL/FAKRA connector

I have had a lot of trouble with the Realsense cameras over USB in the past. Lot of times it is connection drops due to vibration or bandwith saturation in the USB Bus. I recently found out about the FAKRA connector from a friend. I need to do more reading about this but looks like this could solve some of the issues I was seeing.

References

Autogenerate Python bindings

We have been writing a lot of python bindings for C++ code at work. Someone asked me why we need to write a lot of boilerplate code in pybind11 to create these python bindings. I personally prefer the level of configurability that pybind provides in the bindings. But it also made me think, a lot of the time my bindings are just the function name converted from CamelCase to snake_case. I went out to search for tools that automate this binding generation. I found two tools that seem to be actively maintained

  1. Binder

    Binder is a tool for automatic generation of Python bindings for C++11 projects using Pybind11 and Clang LibTooling libraries. That is, Binder, takes a C++ project and compiles it into objects and functions that are all usable within Python. Binder is different from prior tools in that it handles special features new in C++11.

  2. litgen

    litgen, also known as Literate Generator, is an automatic python bindings generator for humans who like nice code and APIs.
    It can be used to bind C++ libraries into documented and discoverable python modules using pybind11.
    It can also be used as C++ transformation/refactoring tool.

I haven’t tried these out but look very promising.

🖼️ Empire State Of Mind

Empire State

← Newer Page 1 of 19