This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jemfinch
Recipients
Date 2003-10-11.10:59:52
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
I was writing a platform-independent hash function for
pathnames, and the documentation was useless for
determining in which order the arguments to the
reducing function are given.  In the one example given,
the arguments are of the same type, and the reducing
function uses a commutative operator, so it doesn't
matter.  In my case, however, I was doing this:

 >>> reduce(lambda h, s: h ^ hash(s),
s.split(os.path.sep), 0)
-740391245

where the arguments aren't the same type, so order does
matter.  I actually tried this first (since it's the
order of arguments of foldl in Haskell/SML):

>>> reduce(lambda s, h: h ^ hash(s),
s.split(os.path.sep), 0)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "<stdin>", line 1, in <lambda>
TypeError: unsupported operand type(s) for ^: 'str' and
'int'

Especially considering that the order of arguments here
is counter to the traditional order of arguments for
such functions in functional languages, I think there
should be a note in the documentation about the order
of arguments.
History
Date User Action Args
2007-08-23 14:17:38adminlinkissue821701 messages
2007-08-23 14:17:38admincreate