Str.format () dla Pythona 2.6 daje błąd, gdy 2.7 nie
Mam pewien kod, który działa dobrze w Pythonie 2.7.
Python 2.7.3 (default, Jan 2 2013, 13:56:14)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from sys import stdout
>>> foo = 'Bar'
>>> numb = 10
>>> stdout.write('{} {}\n'.format(numb, foo))
10 Bar
>>>
Ale w 2.6 otrzymuję wyjątek ValueError.
Python 2.6.8 (unknown, Jan 26 2013, 14:35:25)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from sys import stdout
>>> foo = 'Bar'
>>> numb = 10
>>> stdout.write('{} {}\n'.format(numb, foo))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: zero length field name in format
>>>
Przeglądając dokumentację (2.6, 2.7), Nie widzę żadnej wzmianki o zmianach dokonanych między dwiema wersjami. Co tu się dzieje?