Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Developer's Guide to Python 3.0: Python 2.6 and Migrating From 2 to 3

Python 3.0 has been released. Are you ready to migrate your code? Find out what you need to know to make the switch.


advertisement

his is the final article in the Developer's Guide to Python 3.0 series. It covers the Python 2.6 language and how to migrate from Python 2.x to Python 3.0, and discusses:

  • The current state of Python 2.x libraries
  • The right time to migrate
  • How to migrate
  • What migration tools are available

Python 2.6

Python 2.6 (2.6.2 to be exact) is the latest Python 2.x release. It can run any Python 2.x program "as is." With that said, Python 2.6 and 3.0 were developed in lockstep. Every backwardly compatible feature of Python 3.0 and its standard library modules has been back ported to Python 2.6. That makes Python 2.6 an excellent stepping stone if you want to migrate to Python 3.0. Here's a list of features that Python 2.6 and 3.0 share:

  • PEP-343: The with statement
  • PEP-366: Explicit Relative Imports from a Main Module
  • PEP-370: Per-user Site-packages Directory
  • PEP-371: The Multi-processing Package
  • PEP-3101: Advanced String Formatting
  • PEP-3105: print as a Function
  • PEP-3110: Exception-handling Changes
  • PEP-3112: Byte Literals
  • PEP-3116: New I/O Library
  • PEP-3118: Revised Buffer Protocol
  • PEP-3119: Abstract Base Classes
  • PEP-3127: Integer Literal Support and Syntax
  • PEP-3129: Class Decorators
  • PEP-3141: A Type Hierarchy for Numbers
Author's Note: You can read more about these features in the previous articles in the series (see the Related Resources section).

The ast, json and fractions modules are also available in Python 2.6. Many other changes covered in the earlier Python 3.0 articles are already available in Python 2.6. You can find a comprehensive reference here.



Overall, the Python 2.6/Python 3.0 combination is very impressive, and shows how much effort the Python core developers put into helping developers make the leap from Python 2.x to 3.0. You can safely stay in Python 2.x land, yet still take advantage of many deep 3.0 language-level features such as abstract base classes, class decorators, and even the new exception-handling syntax. Moreover, any efforts you make in that direction will also make migration (when you're ready) that much easier.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap