[docs] "knights of Ni" bug

Sandro Tosi sandro.tosi at gmail.com
Wed Apr 13 18:36:47 CEST 2011


Hi Martin,
thanks for your detailed email :)

On Mon, Apr 11, 2011 at 22:03, Martin Feuchtwanger <martinf at underhill.ca> wrote:
> Hi Sandro, Benjamin, et al.,
>
> Maybe you didn't notice -- i was using 2.6.4

I thought I was using 2.6 but I was on a 2.7, that's the difference in
behaviour :)

> 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

As you already know, the tutorial is for python 2.7 so the syntax can
be different than previous versions.

> 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.

Wikis are an extremely powerful tools, but they need to be updated -
and reader should be aware (generally speaking) wiki can be outdated,
while official documentation is not.

> 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,

exactly that's the problem :)

> 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".

of course this won't happen. Please note that at the beginning of the
tutorial, there's the precise version of it: in your case:

Release:	2.7
Date:	April 13, 2011

> 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.

Wiki.python.org is registration-free: you can create a user (or use an
openid provider, like google) and start updating the pages you feel
need a bit of attention. You'll convert your problematic experience in
a contribution to python, and that would be awesome!

Cheers,
-- 
Sandro Tosi (aka morph, morpheus, matrixhasu)
My website: http://matrixhasu.altervista.org/
Me at Debian: http://wiki.debian.org/SandroTosi


More information about the docs mailing list