Does '#hash' mean anything in IDLE?

John Coleman jcoleman at franciscan.edu
Fri Mar 3 21:46:20 CET 2006


Scott David Daniels wrote:
> John Coleman wrote:
> > Blackbird wrote:
> >> I think this simpler version of letter_hash should work too:
> >>
> >> def letter_hash(word):
> >>     w = [c for c in word]
> >>     w.sort()
> >>     return "".join(w)
>
> And, for 2.4 or later:
>
>      def letter_hash(word):
>          return "".join(sorted(word))
>
> sorted takes an iterable, and strings are iterables.
>
> --Scott David Daniels
> scott.daniels at acm.org

Impressive. It is this ability to create single expressions (like
"".join(sorted(word))) which take the place of entire algorithms in
other languages which I find one of the most striking features of
Python.

-John Coleman




More information about the Python-list mailing list