["python"]
drop into python interpreter while executing function

i have a python module with a function: def do_stuff(param1 = 'a'): if type(param1) == int: # enter python interpreter here do_something() else: do_something_else() is there a way to drop into the command line interpreter where i have the comment? so that if i run the following in python: >>> import my_module >>> do_stuff(1) i get my next prompt in the scope and context of where i have the comment in do_stuff()?
Update for 2023: breakpoint() is included since py3.7 and will drop you into the debugger (pdb by default). If you have other debuggers installed (ipdb, pdbpp, ... to name a few) then breakpoint() will instead drop you into those. Please see these docs for more info: https://docs.python.org/3/library/pdb.html