<html><body><div style="color:#000; background-color:#fff; font-family:arial, helvetica, sans-serif;font-size:12pt"><div>Hi all, </div><div><br></div><div>I'd really like to share this idea of string interpolation for formatting.</div><div>Let's start with some code:</div><div><br></div><div>>>> name = "Shrek"</div><div>>>> print( "Hi, $name$!")</div><div>Hi, Shrek!</div><div>>>> balls = 30</div><div>>>> print( "We have $balls$ balls.")</div><div>We have 30 balls<br></div><div>>>> persons = 5<br></div><div>>>> print ("And $persons$ persons.")</div><div>And 5 persons.</div><div>>>> print(" Each may get exactly $balls//persons$ balls.")</div><div>Each may get exactly 6 balls.</div><div>>>> fraction = 0.12345</div><div>>>> print( "The fraction is $fraction : 0.2f$!")</div><div>The fraction is 0.12!</div><div>>>> print("It costs about $$3, I think.")</div><div>It
 costs about $3, I think.</div><div><br></div><div>I think the rule is quite self explanatory.</div><div>An expression is always enclosed between two '$'s,</div><div>with an optional ':' followed by additional formatting specification.</div><div>Double '$$' is like double '%%'.</div><div><br></div><div>Of course, '$' can be replaced by anything else.</div><div>For compatibility reasons, we might just use '%' as well.</div><div><br></div><div>============</div><div><br></div><div>Implementation: the compiler might need to do something,</div><div>say, to replace a string interpolation with an equivalent </div><div>expression.</div><div><br></div><div>Cheers,</div><div><br></div><div>Yingjie</div></div></body></html>