[Expo-tech] python 2to3 - troggle
Philip Sargent (Gmail)
philip.sargent at gmail.com
Sun May 17 22:23:26 BST 2020
Just for fun I just ran the python 2to3 convert utility on a copy of troggle:
only 35 files touched (out of 76 .py), mostly import, print and raise changes,
and wherever an imported function is used it changes too, and use of Type:
- s = urllib.urlopen(sdir)
+ s = urllib.request.urlopen(sdir)
- if type(surveyNumber)==types.TupleType:
+ if type(surveyNumber)==tuple:
All the changes look very straightforward and don't look as if any would be any trouble at all.
Though some I think are stylistic:
- headers = surveyreader.next()
+ headers = next(surveyreader)
Apart from the odd little thing where it always explicitly casts to a list:
- for key, value in extra_context.items():
+ for key, value in list(extra_context.items()):
Since django >1.5 supports both python2 and python3, and we are on django 1.7
it looks to me that upgrading from python2 to python3 *might* be very quick indeed.
Which would be useful as Ubuntu 20.04 would be a lot happier.
Before I have a go on my copy, has anyone else tried this and if so what gotchas should
I look out for ?
Will the third-party libraries bork badly ?
It looks like imagekit module is not used and is mentioned only in the ancient wiki/externalapps.wiki
(and it looks like troggle used to use https://github.com/feincms/feincms/ but no more)
Philip
PS
This looks much easier than the django upgrades which Sam has been doing
https://docs.djangoproject.com/en/3.0/releases/2.0/
https://docs.djangoproject.com/en/3.0/howto/upgrade-version/
More information about the Expo-tech
mailing list