How to check for single character change in a string?
tinnews at isbd.co.uk
tinnews at isbd.co.uk
Mon Dec 26 17:37:36 EST 2011
Roy Smith <roy at panix.com> wrote:
> In article <roy-AAAEEA.10571424122011 at news.panix.com>,
> Roy Smith <roy at panix.com> wrote:
>
> > >>> len([x for x in zip(s1, s2) if x[0] != x[1]])
>
> Heh, Ian Kelly's version:
>
> > sum(a == b for a, b in zip(str1, str2))
>
> is cleaner than mine. Except that Ian's counts matches and the OP asked
> for non-matches, but that's an exercise for the reader :-)
:-)
I'm actually walking through a directory tree and checking that file
characteristics don't change in a sequence of files.
What I'm looking for is 'unusual' changes in file characteristics
(they're image files with camera information and such in them) in a
sequential list of files.
Thus if file001, file002, file003, file004 have the same camera type
I'm happy, but if file003 appears to have been taken with a different
camera something is probably amiss. I realise there will be *two*
character changes when going from file009 to file010 but I can cope
with that. I can't just extract the sequence number because in some
cases they have non-numeric names, etc.
--
Chris Green
More information about the Python-list
mailing list