String concatenation vs. string formatting

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sun Jul 10 18:48:29 EDT 2011


Roy Smith wrote:

> 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))

I can't believe I didn't think of that. I must be getting sick. (The sore
throat, stuffy nose and puffy eyes may also be a sign.)

Yes, ''.join() is far to be preferred over my solution using "%s".



-- 
Steven




More information about the Python-list mailing list