pep 8 constants
prologic at shortcircuit.net.au
Wed Jan 14 07:58:40 CET 2009
On Wed, Jan 14, 2009 at 4:49 PM, Brendan Miller <catphive at catphive.net> wrote:
> PEP 8 doesn't mention anything about using all caps to indicate a constant.
> Is all caps meaning "don't reassign this var" a strong enough
> convention to not be considered violating good python style? I see a
> lot of people using it, but I also see a lot of people writing
> non-pythonic code... so I thought I'd see what the consensus is.
It may in fact be deliberate. As there really are no
such thing as constants in Python - clearly :)
However, on the rare occasion I need to define
a global variable in a module that gets used in
several places and is more or less used as a
standard configured value - I tend to use ALL CAPS.
Still I would avoid using this idiom altogether
and jsut stick with default values. For Example:
FOO = 1
Use this instead:
More information about the Python-list