Welcome to Python 3
On Christmas Day 1999 I sat down to write my first piece of software in Python. My experience seems to is typical for Python users. I was initially surprised that indentation is significant, it felt scary to not define variables and I were hesitant to us e a dynamic language to make serious software. However, in no time @ All these worries were gone and I noticed I wrote code faster than ever. Months later a friend hired me to he start-up to help him write a content management system and I ended up in the ENVI Able position of being a full time Python developer. I don ' t even mention other languages on my CV anymore, because I don ' t want to use them. I ' ve become a full fledged, fanatic, Pythonista.
I got interested in python 3 for europython 2007 in lovely Vilnius. Guido van Rossums Keynote was on the upcoming changes in python 3 and although he emphatically said so you could Not run the same code under PYTHON 2 and Python 3, I couldn ' t see many reasons why it couldn ' t is done, conside Ring the forward compatibility that is planned for python 2.6. So I started looking @ the differences between PYTHON 2 and Python 3 and tried to find out how to write code th At would run under both versions and learned a whole IoT about Python on the the.
Most surprising is how little the fundamentals has changed. Writing code with Python 3 still feels just like the old comfortable shoes, but newly shined and with new laces. The hardest change-to-get used to IS-remember that printis a function. The relatively small differences doesn ' t necessarily mean that supporting Python 3 are easy, but it can be and hopefully th Is book would make it even easier.
Is it time yet?
Yes, Python 3 is a nicer language to work with. But Python 2 are also very good and the major reason for not switching yet are that Python 2 are so good this most developers Feel little incentive to switch. Although it has been officially declared that Python 2.7 would be the last version of Python 2, it'll receive bug-fixes F Or many years to come, so there are no hurry to change to Python 3 for that reason.
When is should you switch? In general, I would recommend everyone to move to Python 3 as soon as can. If the applications and modules you write is for your or your company's use only, then look in moving when it feels lik E you have the time. If your project is in a state of panic, moving to Python 3 is probably not the right thing to do.
If you are writing software so sell or share as open source, then you want to move more quickly to enable your Custo MERS to move through to Python 3.
If you're writing a package This otherdevelopersuse, every day it doesn ' t support Python 3 is a day-when-you-are Blocking your users from the using Python 3, and a day when Python 3 users has the to look for another the package than yours. In the should really try to add Python 3 support immediately, and if you have dependencies that does not support Python 3, then help with those first.
What if I can ' t switch right now?
In any case all the packagesdepend on need support Python 3 before you can switch. Most packages, support Python 3 is listed on the cheeseshop under the "Python 3 packages" heading[1]. That list was a list of all packages so includes "programming Language:: Python:: 3" as a trove classifier in the Packa GE Meta data. If your dependencies don't support Python 3 It's a good idea to contact the maintainers of your dependencies Plans they has a for Python 3 support. Perhaps they do already support Python 3, but didn ' t update their meta data? Maybe they just didn ' t know anyone is waiting for Python 3 support? Maybe can help?
It's always a good idea to publish information on your plans for Python 3 on your software ' s homepage or in the Descrip tion of the cheeseshop. Include A list of your dependencies that is blocking you. That's the your users can see if there are something they can help with. Open source all are about programmers helping each other; Both using and contributing to each other ' s software. Supporting Python 3 is no different.
And even if you aren ' t switching right now, there is things you can do already. Chapter 3, Preparing for Python 3 lists things-should change before adding Python 3 support, and Chapter 6 improving your code with modern idioms lists modern idioms in Python so you already can use, depending on what Py Thon versions you need to support. To ease the transition to Python 3, many of the new functions and modules in Python 3 has been backported to Python 2.6 o R Python 2.7, and the only thing that stops you from using this already are if you need to support Python 2.5 or earlier.
Python and its versions
Since I started writing this book, Python 2.7 and Python 3.2 has been released. For the purposes of the book, Python 2.6 and Python 2.7 can be seen as equal. So most of the times the book says Python 2.6, you can read that as Python 2.6 or Python 2.7.
Python 3.1 is released quite quickly after Python 3.0 and before any significant adoption of Python 3. Therefore it was decided-to-drop support for Python 3.0. As most platforms-support Python 3 already use Python 3.1 for that support it's unlikely that's ever need to care About Python 3.0. When running your tests under Python 3 I have the to run it with Python 3.1 and Python 3.2, and you can safely ignore P Ython 3.0. So when the this book says Python 3, you can read that as Python 3.1 and later.
Further resources
There is still very little documentation on how to support Python 3. There is a short how-to in the Python 3.2 documentation athttp://docs.python.org/dev/howto/pyporting.html. There is also a page in the official Python wiki at http://wiki.python.org/moin/PortingPythonToPy3k which contain a good l Ist of other resources.
If you need help, or if you want to help out, there is [email protected] mailing list. You can subscribe to it fromhttp://mail.python.org/mailman/listinfo/python-porting.
Footnotes
| [1] |
Http://pypi.python.org/pypi?:action=browse&c=533&show=all |
Original: http://python3porting.com/intro.html
Supporting Python 3 (Support Python3)--Welcome to Python 3