Does '#hash' mean anything in IDLE?

John Coleman jcoleman at franciscan.edu
Fri Mar 3 18:05:02 CET 2006


Blackbird wrote:
> John Coleman <jcoleman at franciscan.edu> skrev:
>
> > John Salerno wrote:
> >> John Coleman wrote:
> >>> John Coleman wrote:
> >>>> Greetings,
> >>>>    I am currently trying to learn Python through the excellent
> >>>> "Learning Python" book.
> >>
> >> me too!
> >>
> >>> It isn't just #hash, but also things like #dict, #int, #len at the
> >>> start of a comment line which defeats IDLE's colorization algorithm.
> >>> Interestingly, things like #while or #for behave as expected so it
> >>> seems to be built-ins rather than keywords which are the problem. To
> >>> answer my own question - this is pretty clearly a (harmless) bug.
> >>
> >> also notice that putting a space after # stops the problem
> >
> > How do you like Python so far? I like dictionary objects the best so
> > far. I'm coming to Python from VBScript, so I already knew the value
> > of such things, but in Python they are better supported.
> >
> > Here is the program I was talking about, which *really* shows the
> > power of dictionaries:
> >
> >
> ****************************************************************************
> *************
> >
> > #Python program to discover word with most 1-word anagrams
> >[...]
>
> Nice!
>
> 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)

Nice suggestion. No need to actually count the multiplicity as long as
you don't lose the information. Your function is much more readable
than mine.

-John Coleman




More information about the Python-list mailing list