Illegal literal or not?
Laura Creighton
lac at strakt.com
Sat Jan 25 17:25:51 EST 2003
> Gerrit Holl wrote:
> >
> > Peter Hansen schreef op zaterdag 25 januari om 20:32:03 +0000:
> > > Mel Wilson wrote:
> > > > >>> print "'" + '"' + "Let's try this!" + '"' + ', they said.' + "'"
> > > > >>> print ''.join (["'", '"', "Let's try this!", '"', ', they said.', "
> '"])
> >
> > > >>> print '"'.join(["'", "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.'
> >
> > :)
>
> Oooohh, very slick. Automatic concatenation of adjacent string
> literals. :-)
>
> <hat mode="doffed"/>
>
> -Peter
> --
> http://mail.python.org/mailman/listinfo/python-list
I think that it is more readable like this:
>>> print "'" '"' "Let's try this!" '"' ', they said.' "'"
'"Let's try this!", they said.'
Laura Creighton
More information about the Python-list
mailing list