2to3
DESCRIPTION
Talk slides for Pycon-India 2010. TopiTRANSCRIPT
![Page 1: 2to3](https://reader036.vdocument.in/reader036/viewer/2022062704/555a71ced8b42ae7218b53c8/html5/thumbnails/1.jpg)
2to3porting summarized - issues, workflows and solutions
![Page 2: 2to3](https://reader036.vdocument.in/reader036/viewer/2022062704/555a71ced8b42ae7218b53c8/html5/thumbnails/2.jpg)
intro /me
• Zubin Mithra
• concurrency, version control, information security
• been working on python for a little more over a year
![Page 3: 2to3](https://reader036.vdocument.in/reader036/viewer/2022062704/555a71ced8b42ae7218b53c8/html5/thumbnails/3.jpg)
today we`ll be discussing
• how different is py3k?
• d2, configobj
• suitable workflow
• how to contribute
• few changes in detail
![Page 4: 2to3](https://reader036.vdocument.in/reader036/viewer/2022062704/555a71ced8b42ae7218b53c8/html5/thumbnails/4.jpg)
how different are they???
![Page 5: 2to3](https://reader036.vdocument.in/reader036/viewer/2022062704/555a71ced8b42ae7218b53c8/html5/thumbnails/5.jpg)
LOTS OF SMALL DIFFERENCES!!!
• http://docs.python.org/release/3.0.1/whatsnew/3.0.html
![Page 6: 2to3](https://reader036.vdocument.in/reader036/viewer/2022062704/555a71ced8b42ae7218b53c8/html5/thumbnails/6.jpg)
a _few_ of them ...
• dict.keys(), dict.values(), dict.items() return views -> not lists
• use sorted(d)
![Page 7: 2to3](https://reader036.vdocument.in/reader036/viewer/2022062704/555a71ced8b42ae7218b53c8/html5/thumbnails/7.jpg)
a _few_ of them ...
• print becomes print()
• map(), filter(), zip() return iterators
• range() behaves like xrange()
![Page 8: 2to3](https://reader036.vdocument.in/reader036/viewer/2022062704/555a71ced8b42ae7218b53c8/html5/thumbnails/8.jpg)
one big change
• “Classic Division”
• Real Division
• Floor Division
• “New Division”
![Page 9: 2to3](https://reader036.vdocument.in/reader036/viewer/2022062704/555a71ced8b42ae7218b53c8/html5/thumbnails/9.jpg)
and a few major ones ...
• All strings are UNICODE
• (int, long) -> int
![Page 10: 2to3](https://reader036.vdocument.in/reader036/viewer/2022062704/555a71ced8b42ae7218b53c8/html5/thumbnails/10.jpg)
2to3 - the tool
![Page 11: 2to3](https://reader036.vdocument.in/reader036/viewer/2022062704/555a71ced8b42ae7218b53c8/html5/thumbnails/11.jpg)
using 2to3
• $ 2to3 -w blah.py
![Page 12: 2to3](https://reader036.vdocument.in/reader036/viewer/2022062704/555a71ced8b42ae7218b53c8/html5/thumbnails/12.jpg)
porting experiences so far
![Page 13: 2to3](https://reader036.vdocument.in/reader036/viewer/2022062704/555a71ced8b42ae7218b53c8/html5/thumbnails/13.jpg)
porting d2
• more than 60 files -> 7200 lines approx.
• d2 has the same codebase for 2.x and 3.x
• run 2to3
• make sure the tests work. fix stuff if they don`t
![Page 14: 2to3](https://reader036.vdocument.in/reader036/viewer/2022062704/555a71ced8b42ae7218b53c8/html5/thumbnails/14.jpg)
porting configobj• converted the repo over to
mercurial
• ran tests (which failed)
• make the tests work
• work not complete! help is appreciated!
• http://bitbucket.org/zubin71/configobj
![Page 15: 2to3](https://reader036.vdocument.in/reader036/viewer/2022062704/555a71ced8b42ae7218b53c8/html5/thumbnails/15.jpg)
single vs. multiple codebases
• Single codebase
• apply bug-fixes once
• codebase becomes messier as you try to increase compatibility with different version
![Page 16: 2to3](https://reader036.vdocument.in/reader036/viewer/2022062704/555a71ced8b42ae7218b53c8/html5/thumbnails/16.jpg)
single vs. multiple codebases
• Multiple codebase
• neater codebase
• apply your bug-fixes on two branches
• you probably have to do this if you intend to re-design your APIs
![Page 17: 2to3](https://reader036.vdocument.in/reader036/viewer/2022062704/555a71ced8b42ae7218b53c8/html5/thumbnails/17.jpg)
single vs. multiple codebases
• expecting rapid development soon?
• use a single branch for now, use another branch when you feel you have enough time to apply patches to 2 branches
![Page 18: 2to3](https://reader036.vdocument.in/reader036/viewer/2022062704/555a71ced8b42ae7218b53c8/html5/thumbnails/18.jpg)
helping the community
• stdlib/3rd party library
• web-frameworks
• python-porting ML
• PSF sponsored sprints
![Page 19: 2to3](https://reader036.vdocument.in/reader036/viewer/2022062704/555a71ced8b42ae7218b53c8/html5/thumbnails/19.jpg)
Unicode and Py3k
![Page 20: 2to3](https://reader036.vdocument.in/reader036/viewer/2022062704/555a71ced8b42ae7218b53c8/html5/thumbnails/20.jpg)
long => integer
![Page 21: 2to3](https://reader036.vdocument.in/reader036/viewer/2022062704/555a71ced8b42ae7218b53c8/html5/thumbnails/21.jpg)
AACK! warning!
• DO NOT use python3.0
• use python3.1
• python3.2 alpha is out. Final release scheduled for Jan 15, 2011
![Page 22: 2to3](https://reader036.vdocument.in/reader036/viewer/2022062704/555a71ced8b42ae7218b53c8/html5/thumbnails/22.jpg)
doubts, anyone?
![Page 23: 2to3](https://reader036.vdocument.in/reader036/viewer/2022062704/555a71ced8b42ae7218b53c8/html5/thumbnails/23.jpg)
well, c u around then!