r/Python • u/glesialo • Oct 27 '14
Help with porting python2 'import' statements to python3.
I wrote a couple of scripts some time ago. They run all right with python2 but I would like to try them with python3. What must I use to replace the following 'import' statements?
import gmenu
import gtk, glib, gobject, gio, gtk.gdk
import re, os
import textwrap
import subprocess
from optparse import OptionParser
from gettext import gettext as _
import gettext
import xdg.IconTheme as xdgiconThanks in advance.
0
Upvotes
-1
u/takluyver IPython, Py3, etc Oct 27 '14
Most of those are easy. The GTK related stuff will be tricky, because the pygtk bindings that you're using only support Python 2. To make it work on Python 3, you'll need to port to the new GObject Introspection bindings. Here's some info about that:
https://wiki.gnome.org/action/show/Projects/PyGObject/IntrospectionPorting?action=show&redirect=PyGObject%2FIntrospectionPorting
http://dumbmatter.com/2012/02/some-notes-on-porting-from-pygtk-to-pygobject/