program to generate data helpful in finding duplicate large files

Steven D'Aprano steve+comp.lang.python at
Fri Sep 19 13:04:39 CEST 2014

Chris Angelico wrote:

> On Fri, Sep 19, 2014 at 3:45 PM, Steven D'Aprano
> <steve+comp.lang.python at> wrote:

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

Ah, so they are!

> 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).
>>> *exit( 0 )*
>> No need to explicitly call sys.exit (just exit won't work) at the end of
>> your code.
> Hmm, you sure exit won't work? 

In the interactive interpreter, exit is bound to a special helper object:

py> exit
Use exit() or Ctrl-D (i.e. EOF) to exit

Otherwise, you'll get NameError.

> I normally use sys.exit 

Like I said, sys.exit is fine :-)

Of course you can "from sys import exit", or "exit = sys.exit", but the OP's
code didn't include either of those.


More information about the Python-list mailing list