[Tutor] Perl Symbology (was: Are you allowed to shoot camels?)

Hugo González Monteverde hugonz-lists at h-lab.net
Thu Feb 10 18:31:50 CET 2005


Smith, Jeff wrote:
> But in my mind nothing beats the Perl statement:
> newstr = "$s $n $r";
> 
> for clarity, ease of use, and maintainability.

Only a little ease of use is lost with the following in Python, clarity 
and maintainability are kept, and it even will let you format the output 
(as in # of decimal places)

newstr = "%{s}s %(n)s %(r)s"%locals()

If you cannot assume a type you can always just use %s...

Hugo



More information about the Tutor mailing list