program to generate data helpful in finding duplicate large files

Chris Angelico rosuav at gmail.com
Fri Sep 19 19:36:33 CEST 2014


On Sat, Sep 20, 2014 at 3:20 AM, Ian Kelly <ian.g.kelly at gmail.com> wrote:
> On Fri, Sep 19, 2014 at 12:45 AM, Chris Angelico <rosuav at gmail.com> wrote:
>> On Fri, Sep 19, 2014 at 3:45 PM, Steven D'Aprano
>>>     s = '\0'.join([thishost, md5sum, dev, ino, nlink, size, file_path])
>>>     print s
>>
>> That won't work on its own; several of the values are integers. So
>> either they need to be str()'d or something in the output system needs
>> to know to convert them to strings. I'm inclined to the latter option,
>> which simply means importing print_function from __future__ and
>> setting sep=chr(0).
>
> Personally, I lean toward converting them with map in this case:
>
>     s = '\0'.join(map(str, [thishost, md5sum, dev, ino, nlink, size,
> file_path]))

There are many ways to do it. I'm not seeing this as particularly less
ugly than the original formatting code, tbh, but it does work.

ChrisA



More information about the Python-list mailing list