Re: custom classes in sets

2005-02-14 Thread Fredrik Lundh
John Machin wrote: > 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. first google hit: http://sebsauvag

Re: custom classes in sets

2005-02-14 Thread John Machin
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 wrestle

Re: custom classes in sets

2005-02-14 Thread Carl Banks
vegetax wrote: > Steven Bethard wrote: > > > vegetax wrote: > >> How can i make my custom class an element of a set? > >> > >> class Cfile: > >> def __init__(s,path): s.path = path > >> > >> def __eq__(s,other): > >>print 'inside equals' > >>return not os.popen('cmp %s %s' % (s.path,oth

Re: custom classes in sets

2005-02-14 Thread Nick Coghlan
vegetax wrote: How can i make my custom class an element of a set? class Cfile: def __init__(s,path): s.path = path def __eq__(s,other): print 'inside equals' return not os.popen('cmp %s %s' % (s.path,other.path)).read() def __hashcode__(s): return s.path.__hashcode__() the idea is that

Re: custom classes in sets

2005-02-14 Thread vegetax
Steven Bethard wrote: > vegetax wrote: >> How can i make my custom class an element of a set? >> >> class Cfile: >> def __init__(s,path): s.path = path >> >> def __eq__(s,other): >>print 'inside equals' >>return not os.popen('cmp %s %s' % (s.path,other.path)).read() >> >> def __ha

Re: custom classes in sets

2005-02-13 Thread Steven Bethard
vegetax wrote: How can i make my custom class an element of a set? class Cfile: def __init__(s,path): s.path = path def __eq__(s,other): print 'inside equals' return not os.popen('cmp %s %s' % (s.path,other.path)).read() def __hashcode__(s): return s.path.__hashcode__() the idea is that

RE: custom classes in sets

2005-02-13 Thread vegetax
Delaney, Timothy C (Timothy) wrote: > vegetax wrote: > >> def __hashcode__(s): return s.path.__hashcode__() > > Try __hash__ ... > > Tim Delaney sorry about the typo, it is indead __hash__() that i tried -- http://mail.python.org/mailman/listinfo/python-list

RE: custom classes in sets

2005-02-13 Thread Delaney, Timothy C (Timothy)
vegetax wrote: > def __hashcode__(s): return s.path.__hashcode__() Try __hash__ ... Tim Delaney -- http://mail.python.org/mailman/listinfo/python-list