Illegal literal or not?

Peter Hansen peter at engcorp.com
Sat Jan 25 16:46:06 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




More information about the Python-list mailing list