String concatenation vs. string formatting

Roy Smith roy at panix.com
Sun Jul 10 16:33:08 CEST 2011


In article <mailman.828.1310280324.1164.python-list at python.org>,
 Andrew Berg <bahamutzero8825 at gmail.com> wrote:

> How should I go about switching from concatenation to string formatting
> for this?
> 
> avs.write(demux_filter + field_filter + fpsin_filter + i2pfilter +
> dn_filter + fpsout_filter + trim_filter + info_filter)
> 
> I can think of a few ways, but none of them are pretty.

The canonical way to do that would be something like

fields = [demux_filter,
          field_filter,
          fpsin_filter,
          i2pfilter,
          dn_filter,
          fpsout_filter,
          trim_filter,
          info_filter]
avs.write(''.join(fields))



More information about the Python-list mailing list