Does hashlib support a file mode?

geremy condra debatem1 at gmail.com
Wed Jul 6 21:15:54 CEST 2011


On Wed, Jul 6, 2011 at 3:07 PM, Phlip <phlip2005 at gmail.com> wrote:
> On Jul 6, 11:42 am, Andrew Berg <bahamutzero8... at gmail.com> wrote:
>> On 2011.07.06 12:38 PM, Phlip wrote:> Python sucks. m = md5() looks like an initial assignment, not a
>> > special magic storage mode. Principle of least surprise fail, and
>> > principle of most helpful default behavior fail.
>>
>> func() = whatever the function returns
>> func = the function object itself (in Python, everything's an object)
>>
>> Maybe you have Python confused with another language (I don't know what
>> exactly you mean by initial assignment). Typically one does not need
>> more than one name for a function/method. When a function/method is
>> defined, it gets created as a function object and occupies the namespace
>> in which it's defined.
>
> If I call m = md5() twice, I expect two objects.
>
> I am now aware that Python bends the definition of "call" based on
> where the line occurs. Principle of least surprise.

Python doesn't do anything to the definition of call. If you call
hashlib.md5() twice, you get two objects:

>>> import hashlib
>>> m1 = hashlib.md5()
>>> m2 = hashlib.md5()
>>> id(m1)
139724897544712
>>> id(m2)
139724897544880

Geremy Condra



More information about the Python-list mailing list