[docs] "knights of Ni" bug

Martin Feuchtwanger martinf at underhill.ca
Mon Apr 11 22:03:41 CEST 2011


Hi Sandro, Benjamin, et al.,

Maybe you didn't notice -- i was using 2.6.4

IDLE 2.6.4
 >>> print 'We are the {} who say "{}!"'.format('knights', 'Ni')

Traceback (most recent call last):
   File "<pyshell#0>", line 1, in <module>
     print 'We are the {} who say "{}!"'.format('knights', 'Ni')
ValueError: zero length field name in format

If you're wondering why i'm using 2.6...
I was following the advice on http://wiki.python.org/moin/BeginnersGuide/Download so i downloaded 
and installed 2.6.4 on my windows work computer. I worked thru the web-based tutorial 
http://docs.python.org/tutorial/ and all was well until i got to the "knights of ni" example, hence 
my first email query.

Interestingly, on the weekend, when i decided to install python on my home computer, i never saw 
any advice re stability on windows {i now realize it is because, silly me, i was getting advice on 
two different python.org web sites}, so i downloaded and installed 3.2 on it. Unfortunately, none 
of the print examples in the web-based tutorial http://docs.python.org/tutorial/ work on 3.2

Python 3.2 (r32:88445, Feb 20 2011, 21:29:02) [MSC v.1500 32 bit (Intel)] on win32
 >>> print 'We are the {} who say "{}!"'.format('knights', 'Ni')
SyntaxError: invalid syntax

Now, i notice that the web tutorial is for python 2.7, and i'm well aware, from other parts of the 
web site, that there are significant changes from python 2 to python 3, and, yes, i know that in 
python 3 print follows strict function syntax, but may i suggest to you, and maybe to the entire 
docs/wiki team,

    * That each tutorial have this added at the beginning:  "Note that this tutorial is version N
      and many of the examples will not work with version N-1 or version N+1 because the silly
      bunts at python.org like to invent a new kind of python with each release".
    * That you explain on both wiki.python.org and docs.python.org that, although they (docs and
      wiki) look the same they are different web sites and contain conflicting information.


Thank you,

one confused cat,

Martin Feuchtwanger, PhD   martinf at underhill.ca   604-732-3384 x 206
Underhill Geomatics Ltd.   www.underhill.ca
210A, 3430 Brighton Ave.   Burnaby, BC            V5A 3H4


On 11/04/2011 11:34 AM, Sandro Tosi wrote:
> Hi Martin,
>
> On Fri, Apr 8, 2011 at 00:08, Martin Feuchtwanger<martinf at underhill.ca>  wrote:
>> Hello,
>>
>> I'm very new to Python -- going through the Tutorial
>> at http://docs.python.org/tutorial/inputoutput.html
>> -- using 2.6.4 (r264:75708, Oct 26 2009, 08:23:19)
>> [MSC v.1500 32 bit (Intel)]
>>
>> I think the following is wrong:
>>
>> 	>>>  print 'We are the {} who say "{}!"'.format('knights', 'Ni')
>> 	We are the knights who say "Ni!"
>>
>> and should be:
>>
>> 	>>>  print 'We are the {0} who say "{1}!"'.format('knights', 'Ni')
>> 	We are the knights who say "Ni!"
>>
>> or am i missing something?
> Benjamin already replied to the other email, and I'm here just to
> reply also to this email.
>
> Why do you think you have to explicitly state the position of the
> objects in the {} format? the numbers can be use to specify a position
> of the objects passed to the string, but if you want to print them as
> they are passed, there's no need to enumerate them.
>
> Regards,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/docs/attachments/20110411/33dfe9aa/attachment.html>


More information about the docs mailing list