pep 8 constants

B

Brendan Miller

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.

Brendan
 
A

Aahz

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.

I've posted to python-dev requesting clarification; you may want to
subscribe to follow the discussion yourself.
 
T

Terry Reedy

Benjamin said:
On Thu, Jan 22, 2009 at 1:16 AM, Aahz <[email protected]

Brendan Miller <[email protected]

constant.

Now it does! See
http://www.python.org/dev/peps/pep-0008/

Thanks for bringing this up!


Since the constants in the std lib (like math.pi and math.e) no longer
follow PEP 8, should we expect them to change at some point in the future?

They are natural rather than arbitrary constants that I usually see in
caps, so I could see them as being in a different subcategory.
 
B

Benjamin Peterson

article said:
Brendan Miller <catphive <at> catphive.net> wrote:>>PEP 8 doesn't mention
anything about using all caps to indicate a constant.Now it does!
 Seehttp://www.python.org/dev/peps/pep-0008/Thanks for bringing this up!
 
Since the constants in the std lib (like math.pi and math.e) no longer follow
PEP 8, should we expect them to change at some point in the future?

No, I don't think so. These are already well known as constants. Besides it
would break backward compatibility for little gain.
 
B

Bruno Desthuilliers

Brendan Miller a écrit :
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.

Most - if not all - of the python code I've seen so far used this
convention, and I always used (and respected) it myself.
 
E

Eric S. Johansson

Bruno said:
Brendan Miller a écrit :

Most - if not all - of the python code I've seen so far used this
convention, and I always used (and respected) it myself.

I reject this convention because any form of caps significantly increases vocal
load for disabled programmers using speech recognition through extra utterances,
and degraded recognition.

In my experience, language conventions like this come about because most geeks
generally don't think about disabled programmers and the effect that language
changes will have on them. I deal by trying to build my accessibility tools as
best I can but handling stuff like pep 8 is hard because it requires a smart
environment that know the meanings of every class, method. or variable so it can
lead the grammar in the right direction. ThenWenUHve names like this. Cr** in a
stick. you might as well take a gun to my wrists because that is how much pain
I will be in typing them. again need *good* editor support for English to name
translation.

so I reject pep 8 because I have no voice safe alternative
 
R

Rhodri James

I reject this convention because any form of caps significantly
increases vocal
load for disabled programmers using speech recognition through extra
utterances,
and degraded recognition.

Reject away, but I'm afraid you've still got some work to do to
convince me that PEP 8 is more work for an SR system than any other
convention. If, on the other hand you're trying to convince me that
*no* convention is preferable, I'm going to laugh hollowly.
 
S

Steven D'Aprano

Bruno said:
Brendan Miller a écrit :

Most - if not all - of the python code I've seen so far used this
convention, and I always used (and respected) it myself.

I reject this convention because any form of caps significantly
increases vocal load for disabled programmers using speech recognition
through extra utterances, and degraded recognition. [...]
so I reject pep 8 because I have no voice safe alternative

And you are perfectly entitled to.

That puts you at a disadvantage if you wish to submit code for the
standard library, where PEP 8 compliance is required, but for your own
code you are entitled to use whatever conventions you prefer.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top