[Qgis-developer] New Python API , "modernity" and Python 2.6.x

gene martin.laloux at gmail.com
Sat Jun 15 02:33:36 PDT 2013


I know that one must be absolutely "modern" (using Python 2.7.x,  too bad for
the others) but the master version of QGIS for Mac Os X is based on the
standard Apple Python, and , unfortunately for me and others, in Snow
Leopard (10.6) it is the version 2.6.
So the first time i try to open the Python console, the result is:

       errors...
       File
"/Users/Shared/QGIS_2.0-dev_SnoLeo.app/Contents/MacOS/../Resources/python/console/console_output.py",
line 137, in insertInitText
    "## Type help(iface) for more info and list of
methods.\n".format(sys.version,  socket.gethostname()))
ValueError: zero length field name in format

and no Python console for me. Why ?

The problem is the line 137 of console_output.py and specially *{} on {}*
which is for Python 2.7.x:
          txtInit = QCoreApplication.translate("PythonConsole",
                                             "*Python {} on {}*\n"
                                             "## Type help(iface) for more
info and list of methods.\n".format(sys.version,  socket.gethostname()))


Forget the new API ?, upgrade Mac OS X ?, no,  because it is very easy  to
make a command  that works in the two versions (2.7 and 2.6):

          txtInit = QCoreApplication.translate("PythonConsole",
                                            "Python {*0*} on {*0*}\n"*
                                             "## Type help(iface) for more
info and list of methods.\n".format(sys.version,  socket.gethostname()))

and:
<http://osgeo-org.1560.x6.nabble.com/file/n5060306/console2.jpg> 





--
View this message in context: http://osgeo-org.1560.x6.nabble.com/New-Python-API-modernity-and-Python-2-6-x-tp5060306.html
Sent from the Quantum GIS - Developer mailing list archive at Nabble.com.


More information about the Qgis-developer mailing list