[Tutor] Defines question?
alan.gauld at blueyonder.co.uk
Sat Jun 5 17:59:42 EDT 2004
> I know in C when you want to define something it would be
> #define MAX_LETTERS 25
>I was wondering what the eqivalent would be in python?
MAX_LETTERS = 25
There is some discussion of adding a const facility to Python
which would allow you to prevent changes, but heh, you can
change it in C if you really want to - just not programmaticlly,
you have to redefine it... :-)
But its one good reason to use the Upper case convention only
for read only variables. At least that way you get a visual
warning that something strange is happening whe you do
MAX_LETTERS = foo
later in the code.
More information about the Tutor