On 02/07/2008, Christopher Spears <[EMAIL PROTECTED]> wrote:
>   File "point.py", line 13, in __str__
>     point_str = "(%f,%f)" % self.x, self.y
>  TypeError: not enough arguments for format string
>
>  Does anyone know what is wrong?  I'm sure it is something obvious, but I 
> can't see it.

Hi Christopher,

Here's the short answer: You need to put brackets around "self.x, self.y"
i.e.     point_str = "(%f,%f)" % (self.x, self.y)

The long answer: Python interprets the statement "point_str =
"(%f,%f)" % self.x, self.y" as "point_str = ("(%f,%f)" % self.x),
self.y".  There are two "%f" expressions in the string, but you only
supplied one argument, self.x.  Thus python tells you that there
aren't enough arguments.  To deal with this, you need to supply the
arguments as a tuple.

-- 
John.
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to