python logo

Python Commandments

Python breakpoint() function

Python 3.7 adds breakpoint(), a function that puts you in the debugger of the calling site.

Specifically, it calls sys.breakpointhook() to pass args and kws directly. by default, sys.breakpointhook() calls pdb.set_trace() without the parameter.

In this case, it’s purely a convenience function, so you don’t have to explicitly import PDB or type enough code to get into the debugger.

However, sys.breakpointhook() can be set to another function, and breakpoint() will automatically call that function, allowing you to access the selected debugger.


breakpoint(*args, **kws)

Description of parameters.

args, *kws - variable length parameters

Return value.

How to use breakpoint()

The following example shows how to use the breakpoint() function

# Before
import pdb;

# Now

args, *kws - difference in variable length parameters

def f(arg,*args,**kwargs):


(2, 4, 5) {'a': 1, 'b': 2}

Python 3.7

You need Python version 3.7 or newer to use breakpoint().

If you’re having troubles, check your python version

python --version

Python 3.7 adds numerous new classes for data processing, optimization for scripting and garbage collection, and faster asynchronous I/O.

Python, a language designed to make complex tasks simple, is officially in beta release with the latest version of Python 3.7, the final version of which is scheduled for June 2018, but no new features will be added to Python 3.7 after that.

The most important additions and improvements to Python 3.7 include the following.

  • Data classes that reduce the sample code when processing data with classes.
  • One change that may not be backward compatible involves handling an exception in the generator.
  • Interpreter-oriented “development model”.
  • A time object with nanosecond resolution.
  • The environment defaults to UTF-8 encoding in UTF-8 mode.
  • Triggers a new built-in function of the debugger.