Arrange files according to a text file

Stephen Hansen me+list/python at ixokai.io
Sun Aug 28 01:31:15 CEST 2011


On 8/27/11 11:06 AM, Emile van Sebille wrote:
> from difflib import SequenceMatcher as SM
> 
> def ignore(x):
>     return x in ' ,.'
> 
> for filename in filenames:
>     ratios = [SM(ignore,filename,username).ratio() for username in
> usernames]
>     best = max(ratios)
>     owner = usernames[ratios.index(best)]
>     print filename,":",owner

It amazes me that I can still find a surprising new tool in the stdlib
after all these years.

Neat.

/pinboards

-- 

   Stephen Hansen
   ... Also: Ixokai
   ... Mail: me+list/python (AT) ixokai (DOT) io
   ... Blog: http://meh.ixokai.io/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 487 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20110827/6a730356/attachment.sig>


More information about the Python-list mailing list