[Tutor] [Q] from Python Tkinter programming

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Thu, 1 Nov 2001 12:22:01 -0800 (PST)


Hello Young Jin,


On Thu, 1 Nov 2001, Young-Jin Lee wrote:

> Hi, I'm trying to learn Python programming and I ran into an odd
> problem. I was reading the sample chapter of "Python and Tkinter
> programming" to learn how to use Tkinter in Python. I downloaded the

Let's take a look!


> sample code and tried to run them in IDLE.  For some reason, I
> couldn't run them in IDLE with the following error.
> 
> Traceback (innermost last)
>   File "c:\yjlee\worx\dissertation\python-related\python and tkinter programming\grayson\examples\chapter11\plot.py", line 404, in ?
>     graph.draw(graphObject, 'automatic', 'automatic')
>   File "c:\yjlee\worx\dissertation\python-related\python and tkinter programming\grayson\examples\chapter11\plot.py", line 226, in draw
>     xticks = self._ticks(xaxis[0], xaxis[1])
>   File "c:\yjlee\worx\dissertation\python-related\python and tkinter programming\grayson\examples\chapter11\plot.py", line 363, in _ticks
>     ticks.append(t, format % (t,))
> TypeError: append() takes exactly 1 argument (2 given)


Ah!  Do you have the page number where this code is?  That looks like a
typo to me; I would have expected:

    ticks.append( (t, format % (t,)) )

because the append() method of lists only take in a single argument.


> The example seems to provide wrong number of argument and I wanted to
> look up the append() method of Python List. But I don't know where I
> to look up. Is there on-line document for all the methods in Python?


Yes, you'll want to look at:

    http://www.python.org/doc/lib/typesseq-mutable.html

Actually, the problem you found with append() is explained in Footnote 1
of the link.  Python used to allow append() to have multiple arguments,
but the designers saw this as a design flaw, so they fixed it so that it
only takes one.



> According to the error message, the example code was wrong, but it is
> hard to believe. I think a lot of people already read this article and
> if so, it should have been updated a long time ago, shouldn't it?

Yes.  It may already be corrected in the author's Errata at,

    http://www.manning.com/Grayson/Errata.html

If you can tell us the page number, we can see if it's already been
corrected by the author, and if not, we should inform the author to
fix his code.


Good luck to you!