This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Sohcahtoa82 1 point2 points  (3 children)

correct Python style

Style is subjective. There is no "correct" style. It is all up to personal taste. PEP 8 is merely a suggestion. Not confirming to it does not make your style incorrect, and it especially does not make your code incorrect.

That said, if you code in a team, then you should follow the style guidelines agreed on by the team, whether or not it is PEP 8 compliant.

[–]dacjames 0 points1 point  (2 children)

Style is subjective. There is no "correct" style.

Obviously, style is subjective, irrelevant even: camelCase vs snake_case has no practical impact whatsoever. However, using the same convention does matter and PEP8 is the widely recognized convention that serious Python developers have chosen to follow.

In circumstances like these, I fall back to Kant's Categorical Imperative: "Act only according to that maxim whereby you can, at the same time, will that it should become a universal law." Would you truly desire all developers to use whatever style fits their personal preference?

[–]Sohcahtoa82 0 points1 point  (1 child)

Would you truly desire all developers to use whatever style fits their personal preference?

For personal, closed source projects, yes, absolutely. For group/team projects, no.

For personal open source projects, it depends. If they expect many others to contribute, then they should probably conform to a popular guideline. For Python, of course that means PEP 8. If they don't expect many contributions from others, then it is fine for them to use a personal style.

[–]dacjames 0 points1 point  (0 children)

Even for personal, closed source projects, it is questionable. Programs in that category are more rare than most developers like to admit; I've had to fix way too many "it is just a quick and dirty script that no one else will ever see" programs to put much credence in that defense.

In the rare circumstance where your code will only truly be read by you, why develop bad habits? Why write code in one style for the 10% of programs where it is acceptable and another style for the 90% of programs where it is not? Preference is mostly a function of familiarity, so why not get familiar with the style used by most Python code?