PDB command <-> variable clashes

  • Thread starter Kääriäinen Anssi
  • Start date
K

Kääriäinen Anssi

I am currently debugging the django test cases, and there are a lot of variables names like w, q, where, condition and so on. Especially variables like w, q, c, r are really annoying. It would be cool if pdb would detect a clash and in that case ask you what to do. Nothing more annoying than stepping through the code, finally finding the problematic place and then trying to find out what c.somevar contains... I am using Python 2.6.

Is there some way to do this? My googling didn't turn out anything. Or is it recommended to use something else instead of pdb?

Thank you for your time,
- Anssi Kääriäinen
 
J

Jon Redgrave

I am currently debugging the django test cases, and there are a lot of variables names like w, q, where, condition and so on. Especially variables like w, q, c, r are really annoying. It would be cool if pdb would detect a clash and in that case ask you what to do. Nothing more annoying than stepping through the code, finally finding the problematic place and then tryingto find out what c.somevar contains... I am using Python 2.6.

Is there some way to do this? My googling didn't turn out anything. Or isit recommended to use something else instead of pdb?

Thank you for your time,
 - Anssi Kääriäinen

Its not perfect but I use in sitecustomize

def precmd(self,l):
if '.' in l:
if l[:1]!='!':l='!'+l
return l
if l in self.curframe.f_locals:
return '!'+l
if l.startswith('@'): return l[1:]
return l
import pdb
pdb.Pdb.precmd = precmd

What this does is
q ->variable q if it exists else quit command
@q ->always quit
!q ->always variable

HTH
Jon
 
M

Miki Tebeka

If you want to view the variable, use the "p" (print) command. Then there is no name clash.
 
M

Miki Tebeka

If you want to view the variable, use the "p" (print) command. Then there is no name clash.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top