Near Final PEP 247 - API for Cryptographic Hash Functions

Robert Amesz reqhye72zux at mailexpire.com
Fri Sep 21 18:48:21 EDT 2001


Andrew Kuchling wrote:

> Second, why should __str__ be the output of .hexdigest() and not
> .digest(), which also returns a string?

See the docs:

      str(object) 
   Return a string containing a nicely printable representation of an
   object. For strings, this returns the string itself. The
   difference with repr(object) is that str(object) does not always
   attempt to return a string that is acceptable to eval(); its goal
   is to return a printable string.

Since the raw digest can (and probably will) contain both control 
characters (< 32) and high-ASCII (> 126) it can't be said te be 'nicely 
printable'.


Robert Amesz




More information about the Python-list mailing list