12.07.2015 Views

Is Python a

Is Python a

Is Python a

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Development Tools for Larger ProjectsOnce you’ve mastered the basics, you’ll find your <strong>Python</strong> programs becoming substantiallylarger than the examples you’ve experimented with so far. For developinglarger systems, a set of development tools is available in <strong>Python</strong> and the publicdomain. You’ve seen some of these in action, and I’ve mentioned a few others. Tohelp you on your way, here is a summary of some of the most commonly used toolsin this domain:PyDoc and docstringsPyDoc’s help function and HTML interfaces were introduced in Chapter 14.PyDoc provides a documentation system for your modules and objects, and integrateswith <strong>Python</strong>’s docstrings feature. It is a standard part of the <strong>Python</strong>system—see the library manual for more details. Be sure to also refer back to thedocumentation source hints listed in Chapter 4 for information on other <strong>Python</strong>information resources.PyCheckerBecause <strong>Python</strong> is such a dynamic language, some programming errors are notreported until your program runs (e.g., syntax errors are caught when a file isrun or imported). This isn’t a big drawback—as with most languages, it justmeans that you have to test your <strong>Python</strong> code before shipping it. Furthermore,<strong>Python</strong>’s dynamic nature, automatic error messages, and exception model makeit easier and quicker to find and fix errors in <strong>Python</strong> than it is in some other languages(unlike C, for example, <strong>Python</strong> does not crash on errors).The PyChecker system provides support for catching a large set of commonerrors ahead of time, before your script runs. It serves similar roles to the “lint”program in C development. Some <strong>Python</strong> groups run their code throughPyChecker prior to testing or delivery, to catch any lurking potential problems.In fact, the <strong>Python</strong> standard library is regularly run through PyChecker beforerelease. PyChecker is a third-party open source package; you can find it at eitherhttp://www.python.org, or the Vaults of Parnassus web site.PyUnit (a.k.a. unittest)In Part V, we saw how to add self-test code to a <strong>Python</strong> file by using the _ _name_ _=='_ _main_ _' trick at the bottom of the file. For more advanced testing purposes,<strong>Python</strong> comes with two testing support tools. The first, PyUnit (called unittest inthe library manual), provides an object-oriented class framework for specifyingand customizing test cases and expected results. It mimics the JUnit frameworkfor Java. This is a sophisticated class-based system; see the <strong>Python</strong> library manualfor details.Core Language Summary | 631

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!