Hi All,<br>I'm a newbie just learning Python, using a couple of books to learn the language. (Books: "Visual Quickstart Guide - Python, 2nd Ed", "Practical Programming - An Intro to Computer Science using Python"). I'm just now learning OOP material as presented in both books -- I'm new to this approach -- the last formal language I learned was Fortran77 -- :o) I am running Python 3.2.1 on Mac OS/X 10.6.8. <br>
<br>My problem stems from a simple example in the Visual Quickstart book. The code is:<br>----------------------------<br>#person.py<br>class Person:<br> """Class to represent a person"""<br>
def __init__(self):<br> <a href="http://self.name">self.name</a>=' '<br> self.age=0<br> def display(self):<br> print("Person('%s', age)" %<br> (<a href="http://self.name">self.name</a>, self.age))<br>
-------------------------<br> When I run this, the shell presents thus:<br>>>> ================================ RESTART ================================<br>>>> <br>>>> p=Person()<br>>>> <a href="http://p.name">p.name</a>='Bob'<br>
>>> p.age=24<br>>>> p.display()<br>Traceback (most recent call last):<br> File "<pyshell#33>", line 1, in <module><br> p.display()<br> File "/Volumes/dean_richardson/GoFlex Home Personal/Dean's Code/Python3.x/Person.py", line 9, in display<br>
(<a href="http://self.name">self.name</a>, self.age))<br>TypeError: not all arguments converted during string formatting<br>>>> <br>---------------<br>I'm sure this is something simple, but I can't see it. Any help appreciated!<br>
<br>Regards,<br>Dean <br><br> <br>