Django Book Gems: assert False
Now that it's been officially released I've started re-reading the Django book, The Definitive Guide to Django: Web Development Done Right. I'm going to start a small series on nice little snippets on bits of great information from the book as I re-read it.
One I found today while reading Chapter 3 was this:
Are you the type of programmer who likes to debug with the help of carefully placed print statements? You can use the Django error page to do so—just without the print statements. At any point in your view, temporarily insert an
assert Falseto trigger the error page. Then, you can view the local variables and state of the program.
I'm the type that uses print (and sometimes pprint) statements when debugging something. And I've even intentionally broke my template syntax to trigger the debug page. But with assert False it becomes way easier. A great tip from the experts!
About this entry
Date Posted:
December 20th 2007 at 11:12:00 AM
Previous Entry:
Django Week in Review, Dec 10 - Dec 16, 2007
Next Entry:
I Can Haz Hardcore Forking Action
Comments
blog comments powered by Disqus