r/AskProgramming • u/Conscious_Breath8953 • Jul 26 '26
Python Is PEP 8 really necessary?
I have been writing Python code using camelCase for years and just never really cared, but PEP 8 suggests using snake_case, so is it really necessary for, say, a senior dev?
0
Upvotes
31
u/AvidCoco Jul 26 '26
You should comply with the coding standards of what ever project, team, or organisation you’re working in.
If they use PEP8, so should you. If it’s your own project, do what you like.
5
u/Take-n-tosser Jul 26 '26
IIRC, PEP8 uses different case schemes depending on what you’re naming (variable, class, method, function, etc)
If you want to put your best foot forward for your portfolio or you’re releasing your project open source, it’s probably worth the time and effort to go back through everything and bring it up to PEP8 standard. It’ll help whoever is reviewing/evaluating your code to fully understand your code and not get distracted by you using a different case scheme than they would.
3
u/abermea Jul 26 '26
If it's a personal project and you're the only person who is going to be handling it then yeah, sure, do whatever you want.
If you're working with other people you should follow PEP8 because working with a baseline standard will make everyone's work easier to both read and update as needed.
2
u/Ok-Armadillo-5634 Jul 26 '26
snake case is pretty standard if you are going to be showing it off then use it
2
u/Garriga Jul 26 '26
I use camelCase and refuse to use snake_case. Python doesn't care whether you write:
def some_function():
or
def someFunction():
This is a convention and not a language requirement. It is equivalent to a writer's style.
3
u/cgoldberg Jul 26 '26
If you want to collaborate with other developers, conformity of style is a huge thing in Python (whereas some language communities don't value it as much).
1
u/Recent-Day3062 Jul 26 '26
I work on my own projects and hire contract programmers.
There are lots of things I dislike in Pep-8. So I tell them to look ast my code and follow that. If I do something different than Pep-8, they should do the same. No one has had a problem with it. I actually a few years back wrote even a brief memo outlining how to fall back on Pep-8, with a list of personal overrides I enforced.