Ferrous Cranus <nikos.gr...@gmail.com> writes:

> pin = int( hashlib.md5( htmlpage ) )
>
> This fails. why?
>
> htmlpage = a string respresenting the absolute path of the requested .html 
> file
> hashlib.md5( htmlpage ) = conversion of the above string to a hashed string

No, that statement does not "convert" a string into another, but rather
returns a "md5 HASH object":

>>> import hashlib
>>> hashlib.md5('foo')
<md5 HASH object @ 0xb76dbcf0>

Consulting the hashlib documentation[1], you could learn about that
object's methods.

> int( hashlib.md5( htmlpage ) ) = conversion of the above hashed string to a 
> number
>
> Why this fails?

Because in general you can't "convert" an arbitrary object instance (in
your case an hashlib.HASH instance) to an integer value. Why do you need
an integer? Isn't hexdigest() what you want?

>>> print _.hexdigest()
acbd18db4cc2f85cedef654fccc4a4d8

Do yourself a favor and learn using the interpreter to test your
snippets line by line, most problems will find an easy answer :-)

ciao, lele.

[1] http://docs.python.org/2.7/library/hashlib.html#module-hashlib
-- 
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
l...@metapensiero.it  |                 -- Fortunato Depero, 1929.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to