building strings from variables

Scott David Daniels scott.daniels at acm.org
Thu Oct 5 20:30:43 CEST 2006


Gal Diskin wrote:
> Following a discussion with an associate at work about various ways to
> build strings from variables in python, I'd like to hear your opinions
> and preferred methods. The methods we discussed are:
> 1.  some_string = "cd %s ; %s  %d %s %s" % ( working_dir, ssh_cmd,
> some_count, some_param1, some_param2)
...
Or another for readability:

   4. some_string = ' '.join(["cd", working_dir, ";",
                  ssh_cmd, str(some_count), some_param1, some_param2])

--Scott David Daniels
scott.daniels at acm.org



More information about the Python-list mailing list