Saturday, 9 May 2020

ipdb.set_trace(context=##) (note to self)

I guess out of comfort it's like the n+1th move I'd consider (because I keep forgetting how it's done - because it's like the n+1th move I'd consider :) ) to make things easier when debugging with ipdb (yes, I'm a bit of a console guy at times), even though it often deserves to be there from the very beginning

You can get more context by doing:
ipdb.set_trace(context=21)
And then, there are ways to fix the default setting too (though I guess it will involve every single virtual environment you may have there to work on, so it's ... well, it is a bit of a tradeoff):

 
replace
def set_trace(frame=None, context=3):

with
def set_trace(frame=None, context=20):
in the relevant ipdb package __main__ file, something like

/home/<yourusername>/.virtualenvs/<yourvirtualenvname>/lib/python3.5/site-packages/ipdb/__main__.py


source

I wouldn't be suprised if I wasn't the first to think that an environment variable setting would be desirable, maybe it's out there already (TODO: give it a look).
 

No comments:

Post a Comment