[python-sg] What do you think of this code?
Martin
martin.brochhaus at googlemail.com
Fri Jun 24 15:13:44 CEST 2011
Wow. This is the worst Python code I have ever seen...
On Fri, Jun 24, 2011 at 9:10 PM, George Loo <majorgml at gmail.com> wrote:
> Hi fellow Python programmers,
>
> this code to find duplicate files is quite complicated to read...
> Is this good coding style or was the coder trying to show off? :-)
>
> import sys
>
> check_path = (lambda filepath, hashes, p = sys.stdout.write:
> (lambda hash = hashlib.sha1 (file (filepath).read ()).hexdigest ():
> ((hash in hashes) and (p ('DUPLICATE FILE\n'
> ' %s\n'
> 'of %s\n' % (filepath,
> hashes[hash])))
> or hashes.setdefault (hash, filepath)))())
>
> scan = (lambda dirpath, hashes = {}:
> map (lambda (root, dirs, files):
> map (lambda filename: check_path (os.path.join
> (root, filename), hashes), files), os.walk (dirpath)))
>
> ((len (sys.argv) > 1) and scan (sys.argv[1]))
>
>
> Source:
>
> http://stackoverflow.com/questions/748675/finding-duplicate-files-and-removing-them
> _______________________________________________
> python-sg mailing list
> python-sg at python.org
> http://mail.python.org/mailman/listinfo/python-sg
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-sg/attachments/20110624/95b6beb2/attachment.html>
More information about the python-sg
mailing list