[PyQt] PyQt4 and Python 3.0

Detlev Offenbach detlev at die-offenbachs.de
Sat Oct 4 11:10:12 BST 2008


On Samstag, 4. Oktober 2008, Phil Thompson wrote:
> On Fri, 03 Oct 2008 16:45:12 -0700, Glenn Linderman <glenn at nevcal.com>
>
> wrote:
> > On approximately 10/3/2008 4:25 PM, came the following characters from
> >
> > the keyboard of Phil Thompson:
> >> Personally I think "compatibility wrappers" are a waste of time and
> >> effort.
> >> There are times when you really should rewrite your application (and I
> >> don't care how big it is). PyQt4 is a complete rewrite of PyQt3, SIP5
> >> will
> >> not share any code with SIP4.
> >
> > Interesting philosophy.  Some truth there.  But then it is a big job to
> > do a rewrite, and someone else's release schedule isn't always the right
> > time.
>
> You have a potential problem if one customer wants your app for Py2 and
> another for Py3. In reality I don't see that as a major problem as paying
> customers are going to be the most conservative. I think it will be a while
> before Py3 becomes mainstream.
>
> >> Major transitions (Qt3 => Qt4, Python2 => Python3) should be considered
> >> as
> >> opportunities for rewrites. They should not be treated as "how can I get
> >> from one to the other with as few changes as possible".
> >
> > If the application was old, I might agree.  But here I am, thinking
> > about, and starting to code, a brand new application.
> >
> >> Therefore, to answer your specific question, if you need to deploy your
> >> application within 6 months (as a minimum) then write for Python2. If
>
> you
>
> >> do then don't bother trying to write it with Python3 in mind. By the
>
> time
>
> >> you get to the point when you want a Python3 version you will have
> >> realised
> >> how badly you wrote it in the first place that you will want to rewrite
> >> it
> >> anyway.
> >
> > So say I wish to deploy in 8 months (the reality is, it will be deployed
> > when it is ready, if not sooner, and that depends on how things go with
> > some other projects also)...  I'd like to avoid deploying it twice in
> > succession on different platforms within a couple months... and even if
> > it was deployed in 4 months, I'd hardly know what to rewrite by then.
>
> Unless your have specific customer demands as I mentioned above, then its
> up to you what you deploy.
>
> >> On the other hand, if you did write it correctly in the first place
> >> (something I've never managed) PyQt4 for Python2 will be maintained for
> >> several years - certainly while new versions of Python2 are released.
> >
> > So this implies, just build it for Python 2 and deploy it, and if it
> > works well enough, leave it there until I figure out what rewrites are
> > necessary.  Certainly possible, but I'm already tired of putting "u" in
> > front of my string constants
>
> Which you don't need to do.
>
> > and of converting from QString back to
> > unicode...
>
> ...and avoiding that will be a benefit of moving to PyQt for Py3. It's up
> to you.
>
> Obviously you can take sensible steps when designing your app to minimise
> the changes - keep your GUI code separate from your models and business
> logic, add some "compatibility wrapper" stuff that makes sense in the
> context of your own app.
>
> What I will try and do - probably via the wiki - is to document what the
> incompatibilities will be (though it will be a moving target) so that
> people can try and write for both Py2 and Py3 if that's appropriate for
> their app.

How about creating a tool (script) that converts old code to new code, doing 
the straight forward conversions automatically and marks the more complex 
conversions. Something like the promised py2to3 script (maybe pyqt4to5)?

Detlev
-- 
Detlev Offenbach
detlev at die-offenbachs.de


More information about the PyQt mailing list