Mensanator wrote:
Really? Does that mean you don't use literals, to save the time required to convert them to integers?
I think all he means is that when he *does* use a named constant, he spells it in lower case rather than upper case, e.g. 'twopi' rather than 'TWOPI'. I don't think there's anything much wrong with that. It can be useful sometimes to visually distinguish constants from variables, but it's not a necessity. Also the all- uppercase convention isn't the only way to do that -- it's a C-ism that isn't universally followed in Python. An alternative often used is just to uppercase the first character. Python itself uses that for many of its built-in constants, such as None, True, False. Arguing that functions are usually constants and should therefore have uppercase names is missing the point -- everyone expects them to be constant anyway, so there's no need for a typographical convention to indicate that. In the rare cases where they're not constant, they can usually be named in a way that makes this obvious. (And BTW, looking up a global name is *slower* than using a literal. Although a local name is probably about the same speed as a literal, as they're both array accesses.) -- Greg -- http://mail.python.org/mailman/listinfo/python-list