"ValueError: zero length field name in format" error in Python 3.0,3.1,3.2

Python 2.6 and 3.0 require the field numbers. In Python 2.7 and later and 3.1 and later, they can be omitted.

Changed in version 2.7: The positional argument specifiers can be omitted, so '{} {}' is equivalent to '{0} {1}'.

python2.6.4>>> print '|{0:^12}|{1:^12}|'.format(3,4)
|     3      |     4     |

I'm gonna guess that you are running python 2.6 by accident somehow.

This feature is only available for at least 3.1 if you are using python 3, or 2.7 if you are using python 2.


If you're using Eclipse you should look into Window -> Preferences -> PyDev -> Interpreter - Python. There you have a list of interpreters (with name and location). If for your current project you're using interpreter which is located for example in /usr/bin/python then probably executing /usr/bin/python -V whill give you something like "Python 2.6.6". And there is your answer like Winston Ewert wrote.

(you can add new interperter by simply clicking "New..." button and giving /usr/bin/python3 as "location". Then you have probably to change your project settings (Preferences -> PyDev - Interpreter/Grammar).