12.07.2015 Views

Is Python a

Is Python a

Is Python a

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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

• In the iterator protocol, the X.next() method is renamed to X.__next__(), and anew built-in function, next(X), calls the X.__next__() method on an object (seeChapters 13 and 17).• The built-in functions zip(), map(), and filter() return iterators; use list() toforce construction of a list of results (see Chapters 13 and 17).• Functions may optionally include annotations describing arguments and results:def foo(x: "spam", y: list(range(3))) -> 42*2:, which are simply attached to thefunction object’s foo.func_annotations dictionary attribute at runtime: {'x':"spam", 'y': [0, 1, 2], "return": 84} (see Chapter 15).• The new nonlocal x, y statement allows write access to variables in enclosingfunction scopes (see Chapter 16).• The apply(func, args, kws) function will be removed; use the func(*args,**kws) call syntax instead (see Chapters 16 and 17).• The reduce() built-in function is removed; code a loop like that shown in thisbook instead; lambda, map(), and filter() are retained in 3.0 (see Chapter 17).• All imports become absolute by default, and skip a package’s own directory: usethe new syntax from . import name to invoke today’s relative imports instead(see Chapter 21).• All classes will be new style classes, and will support today’s new style extensions(see Chapter 26).• The class Spam(object) derivation required today for new style classes will notbe required for classes; in 3.0, both today’s standalone “classic” and derived“new-style” classes are automatically considered what is called new-style today(see Chapter 26).• In a try statement, the form except name value becomes except name as value (seeChapter 27).• In a raise statement, raise E, V must be coded as raise E(V) to make an instanceexplicitly (see Chapter 27).• The with/as exceptions context manager feature described in this book is turnedon (see Chapter 27).• All user-defined and built-in exceptions are identified by classes, not strings (seeChapter 28).• User-defined exceptions must derive from the built-in BaseException, the root ofthe exception hierarchy (Exception is its subclass, and suffices as your rootclass); the built-in StandardException class is removed (see Chapter 28).• The package structure of the standard library may be reorganized substantially(see <strong>Python</strong> 3.0 release notes).Preface | xxxix

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

Saved successfully!

Ooh no, something went wrong!