debuggingtestingand profiling debugging ||in this section we will begin by looking at what python does when there is syntax errorthen at the tracebacks that python produces when unhandled exceptions occurand then we will see how to apply the scientific method to debugging but before all that we will briefly discuss backups and version control when editing program to fix bug there is always the risk that we end up with program that has the original bug plus new bugsthat isit is even worse than it was when we startedand if we haven' got any backups (or we have but they are several changes out of date)and we don' use version controlit could be very hard to even get back to where we just had the original bug making regular backups is an essential part of programming--no matter how reliable our machine and operating system are and how rare failures are--since failures still occur but backups tend to be coarse-grainedwith files hours or even days old version control systems allow us to incrementally save changes at whatever level of granularity we want--every single changeor every set of related changesor simply every so many minutesworth of work version control systems allow us to apply changes ( to experiment with bugfixes)and if they don' work outwe can revert the changes back to the last "goodversion of the code so before starting to debugit is always best to check our code into the version control system so that we have known position that we can revert to if we get into mess there are many good cross-platform open source version control systems available--this book uses bazaar (bazaar-vcs org)but other popular ones include mercurial (mercurial selenic com)git (git-scm com)and subversion (subversion tigris orgincidentallyboth bazaar and mercurial are mostly written in python none of these systems is hard to use (at least for the basics)but using any one of them will help avoid lot of unnecessary pain dealing with syntax errors |if we try to run program that has syntax errorpython will stop execution and print the filenameline numberand offending linewith caret (^underneath indicating exactly where the error was detected here' an examplefile "blocks py"line if blockoutput save_blocks_as_svg(blockssvgsyntaxerrorinvalid syntax