comparing datetime with date

Peter Hansen peter at engcorp.com
Tue Sep 14 21:00:42 EDT 2004


Graeme Matthew wrote:

>>>>str(y)
> '2004-09-14 06:43:15'
>>>>str(x)
> '2004-09-14'

> Even though there string values are different they still match?
> 
> If we perform a CRC (Cyclic Redundancy Check) i.e compute a one way hash:
> 
> import binascii
> 
>>>>crc_x = binascii.crc32(str(x))
>>>>crc_y = binascii.crc32(str(y))
>>>>print crc_x == crc_y
> 
> False
> 
> So this confirms that there values do differ yet a comparision using ==
> returns True?

I'm unclear why you think this binascii.crc32 stuff has anything
to do with anything.  The strings are different, as you showed.

Ignoring collisions (which would be rare) two different strings
are going to have different CRC32 values.  Did you confuse yourself
somewhere along the way?

(Now if the CRC values for those two strings were the same, *that*
would indeed be interesting.)

-Peter



More information about the Python-list mailing list