PFK Errata

20 Feb, 2013

Piotr Słowik writes:

I'm learning how to code from your book. It's great! First time in my life I'm starting to understand how to write code and make it work ;) You're the first person whose teachings make sense to me!

But I have problem with this example:

>>> v = sys.stdin.readline(13)
He who laughs last thinks slowest
>>> print(v)
He who laughs

Whatever I do I get this error:

readline() takes 1 positional argument but 2 were given

I'm using Python 3.3. Please, help.

Thanks for the email Piotr. It looks like you've found the first 'bug' in the book. That example definitely works -- but it doesn't work in the Python Shell. If you try in the Console, you won't get the error.

The reason for the difference is that the Shell does some magic to replace the stdin object with a version of its own -- and its version of the readline function doesn't have a parameter for the maximum number of characters (hence you get an unexpected error message).

I've added this to the errata page accordingly.