python 2.7 - Are """ syntactic sugar for raw strings? -


from tutorial:

print """ usage: thingy [options]      -h                        display usage message      -h hostname               hostname connect """ 

produces following output:

usage: thingy [options]      -h                        display usage message      -h hostname               hostname connect 

hello = r"this rather long string containing\n\ several lines of text in c."  print hello 

would print:

this rather long string containing\n\ several lines of text in c. 

which suggests me """ notation syntactic sugar raw strings. new python, searching documentation not option me.

are """ text """ , r" text "completely identical semantically?

no

print """a\nb""" print "----" print r"a\nb" >>>  b ---- a\nb 

unless use r or r prefix escape sequences interpreted. straight out of documentation:

unless "r" or "r" prefix present, escape sequences in strings interpreted according rules similar used standard c.

you should reading docs, they're great resource , community lucky people have contributed make python , it's common libraries documented. (in opinion).


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -