[issue418489] unittest string format error

2022-04-10 Thread admin


Change by admin :


--
github: None -> 34407

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: String Format Error.

2008-12-23 Thread Steve Holden
Chris Rebert wrote:
 On Mon, Dec 22, 2008 at 10:19 PM, Paulo Repreza pxrepr...@gmail.com wrote:
 Hi,

 I'm a newbie with python and I recently bought Beginning with Python (Which
 is a book I recommend) but the problem that I'm facing it's the following:

 This is the code:

 #!/usr/bin/python2.5
 # Filename: str_format.py

 age = 25
 name = 'foobar'

 print('{0} is {1} years old'.format(name, age))
 print('Why is {0} playing with that python?'.format(name))


 But when I run the script I receive this error:

 Traceback (most recent call last):
   File str_format.py, line 7, in module
 print('{0} is {1} years old'.format(name, age))
 AttributeError: 'str' object has no attribute 'format'


 It is an error because of the version that I'm using ? Python 2.5.2 (Debian
 lenny)
 
 Yes, Python 2.6 or higher is required to use .format() according to
 http://docs.python.org/whatsnew/2.6.html
 
For a replacement that will work in 2.5, see the % sign as an operator
(sometimes called string interpolation).

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.com/

--
http://mail.python.org/mailman/listinfo/python-list


Re: String Format Error.

2008-12-23 Thread Paulo Repreza
Thank You!

On Tue, Dec 23, 2008 at 3:49 AM, Steve Holden st...@holdenweb.com wrote:

  Chris Rebert wrote:
  On Mon, Dec 22, 2008 at 10:19 PM, Paulo Repreza pxrepr...@gmail.com
 wrote:
  Hi,
 
  I'm a newbie with python and I recently bought Beginning with Python
 (Which
  is a book I recommend) but the problem that I'm facing it's the
 following:
 
  This is the code:
 
  #!/usr/bin/python2.5
  # Filename: str_format.py
 
  age = 25
  name = 'foobar'
 
  print('{0} is {1} years old'.format(name, age))
  print('Why is {0} playing with that python?'.format(name))
 
 
  But when I run the script I receive this error:
 
  Traceback (most recent call last):
File str_format.py, line 7, in module
  print('{0} is {1} years old'.format(name, age))
  AttributeError: 'str' object has no attribute 'format'
 
 
  It is an error because of the version that I'm using ? Python 2.5.2
 (Debian
  lenny)
 
  Yes, Python 2.6 or higher is required to use .format() according to
  http://docs.python.org/whatsnew/2.6.html
 
 For a replacement that will work in 2.5, see the % sign as an operator
 (sometimes called string interpolation).

 regards
  Steve
 --
 Steve Holden+1 571 484 6266   +1 800 494 3119
 Holden Web LLC  http://www.holdenweb.com/

 --
 http://mail.python.org/mailman/listinfo/python-list

--
http://mail.python.org/mailman/listinfo/python-list


String Format Error.

2008-12-22 Thread Paulo Repreza
Hi,

I'm a newbie with python and I recently bought Beginning with Python (Which
is a book I recommend) but the problem that I'm facing it's the following:

*This is the code:
*
#!/usr/bin/python2.5
# Filename: str_format.py

age = 25
name = 'foobar'

print('{0} is {1} years old'.format(name, age))
print('Why is {0} playing with that python?'.format(name))


*But when I run the script I receive this error:

*Traceback (most recent call last):
  File str_format.py, line 7, in module
print('{0} is {1} years old'.format(name, age))
AttributeError: 'str' object has no attribute 'format'


It is an error because of the version that I'm using ? Python 2.5.2 (Debian
lenny)

Thanks in advance.
--
http://mail.python.org/mailman/listinfo/python-list


Re: String Format Error.

2008-12-22 Thread Chris Rebert
On Mon, Dec 22, 2008 at 10:19 PM, Paulo Repreza pxrepr...@gmail.com wrote:
 Hi,

 I'm a newbie with python and I recently bought Beginning with Python (Which
 is a book I recommend) but the problem that I'm facing it's the following:

 This is the code:

 #!/usr/bin/python2.5
 # Filename: str_format.py

 age = 25
 name = 'foobar'

 print('{0} is {1} years old'.format(name, age))
 print('Why is {0} playing with that python?'.format(name))


 But when I run the script I receive this error:

 Traceback (most recent call last):
   File str_format.py, line 7, in module
 print('{0} is {1} years old'.format(name, age))
 AttributeError: 'str' object has no attribute 'format'


 It is an error because of the version that I'm using ? Python 2.5.2 (Debian
 lenny)

Yes, Python 2.6 or higher is required to use .format() according to
http://docs.python.org/whatsnew/2.6.html

Cheers,
Chris

-- 
Follow the path of the Iguana...
http://rebertia.com
--
http://mail.python.org/mailman/listinfo/python-list