Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is PEP-8 dead?
#1
(in this forum?!)

Dear moderation team,

Aren't you tired of the herds of camelCase in the demonstrated code?

Though I understand that many of member come to the forum - quoting an admin of some Python group
Quote:for a quick fix
, don't you think pointing out a code that is not PEP-8 compliant should get some priority?

Shouting out bad code practices - especially when provided as an advance example - seems like a good idea too. And speaking of tabs Wall ....
Test everything in a Python shell (iPython, Azure Notebook, etc.)
  • Someone gave you an advice you liked? Test it - maybe the advice was actually bad.
  • Someone gave you an advice you think is bad? Test it before arguing - maybe it was good.
  • You posted a claim that something you did not test works? Be prepared to eat your hat.
Reply
#2
(Oct-20-2018, 09:39 AM)volcano63 Wrote: Aren't you tired of the herds of camelCase in the demonstrated code?
Sure,but can not do anything else than mention that camelCase is not okay style in Python.
(Oct-20-2018, 09:39 AM)volcano63 Wrote: Shouting out bad code practices
No need to shout it out,can mention PEP-8,an give example with better code style.
A site pep8.org with better CSS layout for PEP-8.
Reply
#3
(Oct-20-2018, 11:07 AM)snippsat Wrote:
(Oct-20-2018, 09:39 AM)volcano63 Wrote: Aren't you tired of the herds of camelCase in the demonstrated code?
Sure,but can not do anything else than mention that camelCase is not okay style in Python.

Noone usually bothers to.

(Oct-20-2018, 11:07 AM)snippsat Wrote:
(Oct-20-2018, 09:39 AM)volcano63 Wrote: Shouting out bad code practices
No need to shout it out,can mention PEP-8,an give example with better code style.
A site pep8.org with better CSS layout for PEP-8.

"Bad programming practice" is not necessarilly PEP-8 - some glaring examples
  • Redundant (and ugly) boolean tests cond == True and cond is True
  • Comprehensions to call functions in a loop [print(obj) for obj in objects]
  • Redundant elses and continues (I loved continue Snooty in the last conditional expression in the loop Naughty )
, and last time I tried, I got an extensive lesson in Brainfuck Doh .

Considering that advice to abandon Python 2 is given freely, I find it strange that noone bothers to help educate newbies in Python do nots. Sometimes not for the sake of the poster (who may be quite a PITA about accepting constructive criticism), but for the sake of another newbies who do not know better.
Test everything in a Python shell (iPython, Azure Notebook, etc.)
  • Someone gave you an advice you liked? Test it - maybe the advice was actually bad.
  • Someone gave you an advice you think is bad? Test it before arguing - maybe it was good.
  • You posted a claim that something you did not test works? Be prepared to eat your hat.
Reply
#4
(Oct-20-2018, 11:26 AM)volcano63 Wrote: I find it strange that noone bothers to help educate newbies in Python do nots.
That not right i and others have mention problem you take up here in a lot of Threads.
We have a tutorial about it [Basic] Naming Conventions (PEP 8).
Reply
#5
I am opposed to the moderation team enforcing PEP-8 in any way. PEP-8 is a style guide, not the style guide. Guido has clearly stated that it was not meant to be the be-all end-all for all Python coding. It was only meant as the style guide for the code in the standard library, and not even all of that meets the strict definition of it. And as PEP-8 says, "Consistency within a project is more important" than consistency with PEP-8. Among other things, I think that means that if their teacher is using camelCase, they should be using camelCase.

As for bad coding practices, that's up to the users of the board, not the moderation team. I often do it when dealing with newbies. I don't always detail all the problems, especially in larger bits of code, but rather the things that pop out at me.

I can read camelCase fine, and I would be quite happy if no one on this board ever pointed out that posted code was not PEP-8 compliant.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#6
(Oct-20-2018, 02:06 PM)ichabod801 Wrote: And as PEP-8 says, "Consistency within a project is more important" than consistency with PEP-8. Among other things, I think that means that if their teacher is using camelCase, they should be using camelCase.

Well, newbies are so much into established projects Liar . As about so-called "teachers" - I have heard many complains about quickly-retrained instructors teaching un-Pythonic habits - besides un-Pythonic style.

As usual, I have probably wasted my breath. Moderation can be about teaching the Python way... I should pobably just shut up and keep expanding my ignore list
Test everything in a Python shell (iPython, Azure Notebook, etc.)
  • Someone gave you an advice you liked? Test it - maybe the advice was actually bad.
  • Someone gave you an advice you think is bad? Test it before arguing - maybe it was good.
  • You posted a claim that something you did not test works? Be prepared to eat your hat.
Reply
#7
Even in the main python documentation there are examples of code that is not PEP8/best practice compliant. I don't think we have to enforce PEP-8. I always mention when the code under discussion is not PEP8 compliant, but I have nether the time nor desire to correct everything. Also sometimes code under discussion is so non-pythonic that CamelCase is the least of problems.
Finally, as PEP8 states
Quote:Many projects have their own coding style guidelines. In the event of any conflicts, such project-specific guides take precedence for that project.
A Foolish Consistency is the Hobgoblin of Little Minds

One of Guido's key insights is that code is read much more often than it is written. The guidelines provided here are intended to improve the readability of code and make it consistent across the wide spectrum of Python code. As PEP 20 says, "Readability counts".

A style guide is about consistency. Consistency with this style guide is important. Consistency within a project is more important. Consistency within one module or function is the most important.

However, know when to be inconsistent -- sometimes style guide recommendations just aren't applicable. When in doubt, use your best judgment. Look at other examples and decide what looks best. And don't hesitate to ask!

In particular: do not break backwards compatibility just to comply with this PEP!

Some other good reasons to ignore a particular guideline:

When applying the guideline would make the code less readable, even for someone who is used to reading code that follows this PEP.
To be consistent with surrounding code that also breaks it (maybe for historic reasons) -- although this is also an opportunity to clean up someone else's mess (in true XP style).
Because the code in question predates the introduction of the guideline and there is no other reason to be modifying that code.
When the code needs to remain compatible with older versions of Python that don't support the feature recommended by the style guide.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#8
I don't think about pep-8 at all. I don't even care about it too much. All I care about is to write readable for me and the others code. This is enough to fit into pep-8.

Btw, Reymont Hettinger has something to say about this: https://www.youtube.com/watch?v=wf-BqAjZb8M
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#9
(Oct-20-2018, 02:06 PM)ichabod801 Wrote: I am opposed to the moderation team enforcing PEP-8 in any way. PEP-8 is a style guide, not the style guide. Guido has clearly stated that it was not meant to be the be-all end-all for all Python coding. It was only meant as the style guide for the code in the standard library, and not even all of that meets the strict definition of it. And as PEP-8 says, "Consistency within a project is more important" than consistency with PEP-8. Among other things, I think that means that if their teacher is using camelCase, they should be using camelCase.

As for bad coding practices, that's up to the users of the board, not the moderation team. I often do it when dealing with newbies. I don't always detail all the problems, especially in larger bits of code, but rather the things that pop out at me.

I can read camelCase fine, and I would be quite happy if no one on this board ever pointed out that posted code was not PEP-8 compliant.
(Oct-20-2018, 03:32 PM)wavic Wrote: All I care about is to write readable for me and the others code. This is enough to fit into pep-8.
I think these posts hit the nail on the head of my opinion as well.

However one thing that drives me nuts is when people use something other than 4 space indentation (especially the 1,2, or 3 spaced indents). I usually will mention to them about pep 8. But that does not mean i would invoke a rule that you have to post 4 spaces to be allowed to post here.

the only thing i think mods be required to do is maintain a friendly environment, remove spam, and make posts easier to read (at least informing users to put their code in code tags, if not do it for them, fix bad titles, etc.).

(Oct-20-2018, 09:39 AM)volcano63 Wrote: don't you think pointing out a code that is not PEP-8 compliant should get some priority?
I do think our tutorials should be PEP 8 complaint, but that is just my opinion. And especially if the person asks how to make their code better.
Recommended Tutorials:
Reply
#10
I think most of the code I share follows pep8, with the exception of list comprehensions doing side effects (I'm an offender on that one).

I feel that it's more important to offer a friendly atmosphere, so people are more likely to come back the next time they need help (instead of jumping ship to something like Rust, which has an absolutely incredible community). To that end, I don't personally view pep8 comments as incredibly constructive, unless their code has gotten large enough where it's actively difficult to understand. ...or every variable is a single letter, in complex calculations that are completely without description (that really grinds my gears lol)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Is comp.lang.python dead? Winfried 3 4,660 Aug-25-2018, 12:04 AM
Last Post: metulburr
  WYSIWYG dead, source mode enabled metulburr 0 2,804 May-31-2017, 01:26 PM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020