On Mon, Sep 7, 2009 at 11:48 PM, Jim <jim.heffe...@gmail.com> wrote:

>
> On Sep 7, 7:30 pm, Joshua Russo <josh.r.ru...@gmail.com> wrote:
>  > I then switched to just using Textpad with Python highlighting and
> pdb, (http://docs.python.org/library/pdb.html) for debugging. Once you
> get the
> > hang of pdb it's extremely powerful. It basically drops you right into
> the
> > code with a Python command line. If you don't yet have experience with
> the
> > Python command line I would highly recommend getting a feel for it.
>
> I must be doing something wrong.  I have never been able to get a
> sensible output from pdb.  Is there a web page with an illustration of
> using it with Django that you could recommend?


I had a little difficulty with the Python docs on this one too. As it turns
out it's really simple. Put the following line where ever you want a break
point.

import pdb; pdb.set_trace()

The Django dev server window will stop with a Python command line prompt
right there and you have access to all of the context the current code in
the application has. It's extremely handy for testing different variations
of a given line and that the context is what you expect.

Another function I use all the time at the Python command line is dir().
Pass any object or property into it and it will list the available
properties and methods. This in combination with pprint() that formats list
output in a tree view style. I usually import pprint like so from the
command line: from pprint import pprint as pp. Then you can do:
pp(dir(object)) or pp(dir(obect.property))

I hope this helps.

Josh

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to