unicode and hashlib

Scott David Daniels Scott.Daniels at Acm.Org
Sun Nov 30 19:16:18 CET 2008

Jeff H wrote:
> ...
 > decode vs encode
> You decode from on character set to a unicode object
> You encode from a unicode object to a specifed character set

Pretty close:

     Think of characters a "conceptual" -- you encode a character
string into a bunch of bytes (unicode -> bytes) in order to send
the characters along a wire, into an e-mail, or put in a database.

     You got the bytes from the wire, database, Morse code, whatever.
You decode the byte stream into characters, and now you really have
characters.  Thinking of it this way makes it clear which name is
which, unless (as I did once in this thread) you switch opposite
concepts carelessly.

Characters are content (understood by humans), bytes are gibberish
carried by hardware which likes that kid of thing.  You encode a
message into nonsense for your carrier to carry to your recipient,
and the recipient decodes the nonsense back into the message.

--Scott David Daniels
Scott.Daniels at Acm.Org

More information about the Python-list mailing list