[Tutor] Printing Problem python 3

Kent Johnson kent37 at tds.net
Wed Apr 29 21:03:13 CEST 2009


On Wed, Apr 29, 2009 at 2:42 PM, Dave Crouse <dcml1 at crouse.us> wrote:
> Trying to print something with a { in it.
> Probably extremely simple, but it's frustrating me.  :(
>
> print ('The \"This is a test \" {')
>
> i get this error
>
> ValueError: Single '{' encountered in format string

It works for me:
Python 3.0.1 (r301:69561, Feb 13 2009, 20:04:18) [MSC v.1500 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> print ('The \"This is a test \" {')
The "This is a test " {

I guess you have redefined print() to use the latest style of string formatting:
http://www.python.org/dev/peps/pep-3101/

Try using double braces {{

Kent


More information about the Tutor mailing list