building strings with variable input

Olaf Meyer nomail at nospam.net
Mon Jan 12 10:58:45 CET 2004


Sometimes if find it clumsy unsing the following approach building strings:

cmd = "%s -start %s -end %s -dir %s" % (executable, startTime, endTime, 
directory)

Especially if you have a lot of variable input it makes it hard to match 
the variables to the proper fields. From other scripting languanges I'm 
used to something like:

  $cmd = "$executable -start $startTime -end $endTime -dir $directory"

This makes it very easy to see how the string is actually built. You 
dont't have to worry where which variables go.

Is there a similar way to do this in python?

Thanks,
   Olaf



More information about the Python-list mailing list