Thank You!<br><br>
<div class="gmail_quote">On Tue, Dec 23, 2008 at 3:49 AM, Steve Holden <span dir="ltr"><<a href="mailto:steve@holdenweb.com">steve@holdenweb.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div>
<div></div>
<div class="Wj3C7c">Chris Rebert wrote:<br>> On Mon, Dec 22, 2008 at 10:19 PM, Paulo Repreza <<a href="mailto:pxrepreza@gmail.com">pxrepreza@gmail.com</a>> wrote:<br>>> Hi,<br>>><br>>> I'm a newbie with python and I recently bought Beginning with Python (Which<br>
>> is a book I recommend) but the problem that I'm facing it's the following:<br>>><br>>> This is the code:<br>>><br>>> #!/usr/bin/python2.5<br>>> # Filename: str_format.py<br>>><br>
>> age = 25<br>>> name = 'foobar'<br>>><br>>> print('{0} is {1} years old'.format(name, age))<br>>> print('Why is {0} playing with that python?'.format(name))<br>>><br>
>><br>>> But when I run the script I receive this error:<br>>><br>>> Traceback (most recent call last):<br>>>   File "str_format.py", line 7, in <module><br>>>     print('{0} is {1} years old'.format(name, age))<br>
>> AttributeError: 'str' object has no attribute 'format'<br>>><br>>><br>>> It is an error because of the version that I'm using ? Python 2.5.2 (Debian<br>>> lenny)<br>><br>
> Yes, Python 2.6 or higher is required to use .format() according to<br>> <a href="http://docs.python.org/whatsnew/2.6.html" target="_blank">http://docs.python.org/whatsnew/2.6.html</a><br>><br></div></div>For a replacement that will work in 2.5, see the "%" sign as an operator<br>
(sometimes called "string interpolation").<br><br>regards<br> Steve<br>--<br>Steve Holden        +1 571 484 6266   +1 800 494 3119<br>Holden Web LLC              <a href="http://www.holdenweb.com/" target="_blank">http://www.holdenweb.com/</a><br>
<font color="#888888"><br>--<br><a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br></font></blockquote></div><br>