[Tutor] colours in IDLE
moron.oxy at gmail.com
Wed Apr 15 11:36:10 CEST 2009
On Wed, Apr 15, 2009 at 7:29 PM, mbikinyi brat <mbikinyi_brat at yahoo.com> wrote:
> Dear ALL,
> When you type a code in IDLE-Python, they appear in different colours.
> For instance:
> def factorial(n):
> if n==0:
> return 1
> return result
> factorial in blue and return and else and result in red.
> Any significance to these colours?
That's called "syntax-highlighting", it basically allows you to read
the code clearer. Different Python language constructs are given
appropriate colours. I don't use IDLE myself, but in your example,
'factorial' - is a function name - an identifier in general, that's
assigned one colour, whereas 'def', 'else', 'return' are Python
keywords - you cannot use these as identifiers - they're assigned yet
another colour. Keywords, braces, operators, identifiers - these
constitute the 'syntax' of Python. Hence using colours highlights the
syntax so it's easier to read -- syntax-highlighting ;-).
More information about the Tutor