Illegal literal or not?

Grzegorz Adam Hankiewicz gradha at
Fri Jan 24 20:05:43 CET 2003

On Fri, Jan 24, 2003 at 06:46:18PM +0000, LJ & MT Lareau wrote:
> Is it possible to have Python produce the following literal output
> in the interactive mode.
> '"Let's try this!", they said.'
> If so what is the Python statement. I've tried several ways and
> can't seem to produce it.  Thanks for the help.

See this interactive session (lines separated, to be more readable):

[gregorio at] [~]$ python
Python 2.2.1 (#1, Apr 21 2002, 08:38:44) 
[GCC 2.95.4 20011002 (Debian prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

>>> print """'"Let's try this!", they said.'"""

'"Let's try this!", they said.'

>>> print "'\"Let's try this!\", they said.'"

'"Let's try this!", they said.'

>>> print '\'"Let\'s try this!", they said.\''

'"Let's try this!", they said.'

More information about the Python-list mailing list