Does '#hash' mean anything in IDLE?

John Coleman jcoleman at
Thu Mar 2 21:42:39 CET 2006

John Coleman wrote:
> Greetings,
>    I am currently trying to learn Python through the excellent
> "Learning Python" book. I wrote my first non-trivial program, which
> began with several comment lines. One of the comment lines began  with
> '#hash'. IDLE doesn't colorize it as a comment line but instead colors
> the word 'hash' in purple as if it were a key word. Wierd. The behavior
> seems easy to trigger: Just open up a new window in IDLE and enter
> these two lines:
> #This is a test
> #hash should still be a comment line
> Then, after saving, the second line is not colored as a comment line
> though the first is.
> Is this a bug, or do comment lines which begin with #hash have some
> special meaning?
> My program ran fine, so it seems that the interpreter itself is
> ignoring the line.
> -John Coleman

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.

-John Coleman

More information about the Python-list mailing list