Hi, On Wed, Apr 15, 2009 at 7:29 PM, mbikinyi brat <[email protected]> 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 > else: > recurse=factorial(n-1) > result=n*recurse > 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 ;-). _______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
