pep 8 constants

Steven D'Aprano steven at
Tue Jan 20 05:03:05 CET 2009

On Mon, 19 Jan 2009 19:11:16 -0800, Brendan Miller wrote:

>> Constants would be a nice addition in python, sure enough.
> My original question was about PEP-8 and whether it is pythonic to use
> all caps to denote a variable that shouldn't be changed. More of a style
> question than a language question.
> I actually think *enforcing* constantness seems to go against the grain
> of the language so to speek

Why? Python has an infinite number of constants. The only difference is 
that they are immutable objects, not names.

But regardless... yes, it is in my opinion Pythonic to use ALLCAPS to 
designate constants (by convention). It isn't in PEP 8, but I don't think 
that matters unless PEP 8 suggests a different convention.


More information about the Python-list mailing list