News for hackers. Stuff that matters.
Re:Django and Python 3 by wisty on Thursday February 17, 2011 @09:08AM (#2230924)
Here would be my plan (though I'm not good enough to carry it out):

1. Port the dispatcher to P3.

2. Do something magic with urls.py, so you choose which version (2.X or 3.X) you want doing the query.

At this point, people can use URL plumbing to gradually port their Django projects.

3. Port the parts where Python 3 is a killer feature. String formatting, Unicode handling (maybe), function decorators, and metaclasses. This is the hard part - where would python 3 add some killer features to django?

You also need to do the db layer, the templating, and all that jazz, but that should follow once you have the incentive of actually seeing it work in your browser.

Re:Django and Python 3 by ubernostrum on Thursday February 17, 2011 @09:43AM (#2231048)
I've said before and will say again:

The holdup here is not technical. It's great that we've got people like Alex willing to port code, but that's not the hard part. The hard part is people who are using and want to continue using Django on platforms where Python 2.5 or even 2.4 is still the standard.

More on this forthcoming, once I've had a proper weekend off.

Re:Django and Python 3 by glenjamin on Thursday February 17, 2011 @10:33AM (#2231238)
How feasible is it to have support from 2.4 to 3.x? Either with or without 3to2/2to3 as part of the packaging process?

EDIT: I'd have thought upgrading the codebase to 3.x and making sure that 3to2 produces a working 2.4 version would be better than using 2to3. Thoughts?

Re:Django and Python 3 by koenigdavidmj on Thursday February 17, 2011 @11:57AM (#2231646)
The problem there is that 2.4's exception statements and 3.0's have two different meanings.

2.4 only supports this:

    try:
        do stuff
    except FooError, e:
        do stuff with e
3.0 and up choke on this; they interpret it as "catch exceptions of type FooError or e and do not give the exception object a name".

2.5 through 2.7 interpret like 2.4 but also support explicit parentheses to do what Python 3 does:

    try:
        do stuff
    except (FooError, BarError) as e:
        do stuff
    except (BazError, QuxError):
        do other stuff
2to3 requires that you use the new exception syntax only, to avoid confusion.
Re:Django and Python 3 by briancurtin on Thursday February 17, 2011 @12:16PM (#2231743)
The following will work across 3 and 2 versions going back pretty far. It's necessary if you want to support pre-2.5 versions (where `as` was introduced):

    import sys
    try:
        fn()
    except (IOError, TypeError):
        err = sys.exc_info()[1]
        print(err)
http://docs.pythonsprints.com/python3_porting/py-porting.htm...
Re:Django and Python 3 by koenigdavidmj on Friday February 18, 2011 @12:47AM (#2234401)
Still kind of ugly, and not something which you want to litter than Django sources. Especially if you are going to put them all back when 2.4 support is dropped.
Re:Django and Python 3 by kingkilr on Thursday February 17, 2011 @11:28AM (#2231490)
That is precisely my goal, I think it's eminently feasible using 2to3.
Re:Django and Python 3 by scorpion032 on Friday February 18, 2011 @01:09AM (#2234449)
I think django should include magic to fall back to 2.x version when and where 3.x is not available. May be via configuring multiple virtualenvs.
Re:Django and Python 3 by oreilly on Thursday February 17, 2011 @09:09PM (#2233896)
For platforms where an older version of python is standard, can that not be worked around by using virtualenv?
Re:Django and Python 3 by prog on Thursday February 17, 2011 @08:46AM (#2230851)
I started working on an app using Python 2.7. The only reason I chose 2.7 over 3.x was the lack of 3.x support in Django. I would be great to have Django support Python 3.x.
Re:Django and Python 3 by sigzero on Thursday February 17, 2011 @09:08AM (#2230922)
I believe that they already have the rumblings going on to move it to 3.x.
Re:Django and Python 3 by briancurtin on Thursday February 17, 2011 @10:20AM (#2231184)
https://bitbucket.org/loewis/django-3k is the initial 3.x port mentioned in the post, started at PyCon 2008.
Re:Django and Python 3 by clojurerocks on Thursday February 17, 2011 @11:25AM (#2231478)
Its nice to see posts about python and django. Ive only played around with them a little bit but having options is always a good thing and right now it seems the frameworks discussion is really dominated by Rails.
Re:Django and Python 3 by danssig on Thursday February 17, 2011 @08:45AM (#2230843)
So this is an appeal to get taken up for google summer of code? Doesn't google have pages for these kind of requests?
Re:Django and Python 3 by briancurtin on Thursday February 17, 2011 @10:17AM (#2231176)
I think he's aware of the formal procedures from his previous involvement with GSOC and Django. The post seems more to be stating what's what, how it's probably going to happen, etc.
Re:Django and Python 3 by scorpion032 on Thursday February 17, 2011 @12:59PM (#2231963)
This would be Alex's third time at GSoC after MultiDB support and support for non-relational databases, but hugely successful.

Plus Google decides GSoC students on a per project basis and the project's core developers get the pick the students; and Alex, already is a core developer.

Re:Django and Python 3 by vipivip on Thursday February 17, 2011 @09:21AM (#2230969)
Kudos python 3.x