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.

Preparing for <strong>Python</strong> 3.0The first alpha release of <strong>Python</strong> 3.0 came out just before this book went to theprinter, and after it had been written. Officially speaking, this edition of this book isbased on the <strong>Python</strong> 2.x line (specifically, version 2.5), but it has been augmentedwith numerous notes about anticipated changes in the upcoming <strong>Python</strong> 3.0 release.Version 3.0 won’t be officially released until roughly one year after this book hasbeen published, and it isn’t expected to be in wide use for at least two years. Nevertheless,if you’ve picked up this book after 3.0 is in common use, this sectionprovides a brief description of some of the changes in the language you will likelyencounter to help you make the transition.Although there are a few notable exceptions, most of the <strong>Python</strong> language in version3.0 will be the same as described in this book, and the impact on typical and practicalapplications code will be minor. That is, the fundamentals of <strong>Python</strong> presented inthis book will not change from release to release, and readers will benefit by studyingthose fundamentals here first before dealing with release-specific details.To help you retarget code in the future, though, the following list highlights themajor differences in <strong>Python</strong> 3.0. Pointers to the chapters in this edition that eitherdiscuss or are impacted by these changes are noted as well, and the list is ordered byrelevant chapter number. Some of these changes can be coded today in <strong>Python</strong> 2.5, andsome cannot. Because much of the following list won’t make sense to most readers atthis point, I suggest you first study this book at large to learn the fundamentals of<strong>Python</strong>, and return to this list later to see the changes in 3.0. In <strong>Python</strong> 3.0:• The current execfile() built-in function is removed; use exec() instead (seeChapter 3).• The reload() built-in functions may be removed; an alternative is not yet known(see Chapters 3 and 19).• The 'X' backquotes string conversion expression is removed: use repr(X) (seeChapter 5).• The X Y redundant inequality expression is removed: use X!= Y (see Chapter 5).• Sets can be created with new literal syntax {1, 3, 2} equivalent to the currentset([1, 3, 2]) (see Chapter 5).• Set comprehensions may be coded: {f(x) for x in S if P(x)}, which is the sameas the current generator expression: set(f(x) for x in S if P(x)) (see Chapter 5).• True division is turned on: X/Yalways returns a floating-point number thatretains the remainder, even for integers; use X// Y to invoke today’s truncatingdivision (see Chapter 5).• There is only one integer type, int, which supports the arbitrary precision of thecurrent long type (see Chapter 5).Preface | xxxvii

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

Saved successfully!

Ooh no, something went wrong!