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.

when used well. However, you’ll simplify debugging and aid maintainability if youmake your class interfaces intuitive, avoid making your code overly abstract, and keepyour class hierarchies short and flat unless there is a good reason to do otherwise.Chapter SummaryThis chapter presented a handful of advanced class-related topics, including subclassingbuilt-in types, pseudoprivate attributes, new-style classes, static methods,and function decorators. Most of these are optional extensions to the OOP model in<strong>Python</strong>, but they may become more useful as you start writing larger object-orientedprograms.This is the end of the class part of this book, so you’ll find the usual lab exercises atthe end of the chapter—be sure to work through them to get some practice codingreal classes. In the next chapter, we’ll begin our look at our last core language topic,exceptions. Exceptions are <strong>Python</strong>’s mechanism for communicating errors and otherconditions to your code. This is a relatively lightweight topic, but I’ve saved it for lastbecause exceptions are supposed to be coded as classes today. Before we tackle thatfinal subject, though, take a look at this chapter’s quiz and the lab exercises.564 | Chapter 26: Advanced Class Topics

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

Saved successfully!

Ooh no, something went wrong!