testing a sequence for 'identicalness'
Tim Peters
tim.one at comcast.net
Thu Jul 4 13:31:12 EDT 2002
More information about the Python-list mailing list
Thu Jul 4 13:31:12 EDT 2002
- Previous message (by thread): testing a sequence for 'identicalness'
- Next message (by thread): testing a sequence for 'identicalness'
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
[Rajarshi Guha] > does anybody knwo how I can check a sequence for 'identical ness', ie > given a sequence: > > [1,1,1,1,1,1,1,1,1,1] > > it would be classified as 100% identical 100% identical to what? Itself? That's easy <wink>. > and > > [1,1,1,1,1,1,1,1,1,2] > > would be classified as 90% identical. >>> import difflib >>> m = difflib.SequenceMatcher(None, [1]*10, [1]*9 + [2]) >>> print m.ratio() 0.9 >>> Read the difflib docs for more.
- Previous message (by thread): testing a sequence for 'identicalness'
- Next message (by thread): testing a sequence for 'identicalness'
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list