Saturday
4:30 p.m.–5 p.m.
Porting Django apps to Python 3
- Audience level:
- Intermediate
- Category:
- Web Frameworks
Description
Django 1.5 now supports Python 3, so now's the time to start thinking about porting your apps and sites. Come see how! I'll talk about the porting techniques that work, and present two case studies: porting a site, and porting a reusable app.
Abstract
Django 1.5 now supports Python 3, so now's the time to start thinking about porting your apps and sites. Come see how!
I'll cover:
-
Your options [3 mins]
- Single source, Python 3 only - if you only need to run on Python 3, no looking back.
- Shared source, translated (the
2to3
approach) - the "old" recommendation, no longer considered such a good idea.
- Shared source, single codebase - the "new" recommendation: code that runs simultaneously on Python 2 and Python 3, no translation needed.
-
Overview of Python 3 [5 mins]
- Python 3 from a Django/web dev perspective?
- The big change: unicode
- Smaller changes: standard library arrangement, print statement, exception syntax, etc.
-
Porting technique [10 mins]
- Choose an approach - what's your use case?
- Evaluate dependencies - can you port yet?
- Achieve test coverage - how will you know your port works?
- Perform the basic syntax changes - get your test suite to run.
- Make the big change: string/unicode handling.
- Wrap it up: plink away until the test suite passes.
-
Case study 1: porting a project to Python 3 [5 min]
- Only needs python 3, no need for Py 2.
- What worked well?
- What failed?
-
Case study 2: porting a reusable app to Python 3 [5 min]
- Needs to be dual-source (Python 2.7 & 3.3)
- Also dual Django! (1.4+)
- What needs to be different?
- What worked?
- What failed?
-
Questions [5 mins]