Near Final PEP 247 - API for Cryptographic Hash Functions
akuchlin at mems-exchange.org
Tue Sep 25 16:30:45 CEST 2001
"Tim Peters" <tim.one at home.com> writes:
> It's unclear whether all modules conforming to this spec must support both
> flavors of "new". The syntax of the second flavor of new() is also unclear;
> new(key[, string])
> was intended? I expect I'd like it better if the string argument always
> came first, and that hash methods requiring a key require a keyword "key="
That seemed backwards to me. With a keyed hash, the key is required
and a string is optional, so the key should therefore come first.
It's irritating that this can cause potential confusion if you
switched from an unkeyed to a keyed hash -- an initial string can be
interpreted as the key -- but it would be more irritating to have the
first parameter not be the only required one.
A recent suggestion from Rich Salz is to be even more minimal and
simply drop the string argument to the constructor; that's not such a
bad idea, since it ensures TOOWTDI. (Obviously I wouldn't rip out the
initial string argument for the MD5 and SHA modules included with
More information about the Python-list