custom classes in sets
John Machin
sjmachin at lexicon.net
Mon Feb 14 07:26:53 EST 2005
vegetax wrote:
> How can i make my custom class an element of a set?
>
> the idea is that it accepts file paths and construct a set of unique
> files (the command "cmp" compares files byte by byte.),the files can
> have different paths but the same content
>
Q: How do I transport ten sumo wrestlers on a unicycle?
A: With extreme difficulty. You may well need a different vehicle.
Think about your requirements, then implement the most appropriate data
structure. If, as is likely, you need to know which and how many files
are identical, then a set won't do the job by itself. You may need a
union-find gadget.
Then before you rush and implement something, google around and look in
the Tools and Scripts directories in the Python distribution; I'm quite
sure I've seen something like a "duplicate file detector" written in
Python somewhere.
HTH,
John
More information about the Python-list
mailing list