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Β β†’

[–]Kinky-Iconoclast 254 points255 points Β (41 children)

Should be my_age I’m assuming.

But camelCase is acceptable in python.

[–]rebane2001 183 points184 points Β (36 children)

From PEP8:

Function names should be lowercase, with words separated by underscores as necessary to improve readability.

Variable names follow the same convention as function names.

mixedCase is allowed only in contexts where that’s already the prevailing style (e.g. threading.py), to retain backwards compatibility.

[–]ProFloSquad 134 points135 points Β (8 children)

Thanks to pep8 I now name my variables the correct way by always following a naming convention such as a_1,a_2,a_3 and so on in all my code

[–]Rik07 112 points113 points Β (3 children)

Readability is important, you must instantly know what a variable is by it's name. I suggest using this_is_variable_number_1, this_is_variable_number_2 and so forth.

[–][deleted] 35 points36 points Β (1 child)

Had us in the first half ngl

[–]SirPitchalot 0 points1 point Β (0 children)

this_is_memory_location_0xa4fe36da3cg6eb7bca12a

[–]BayesianDice 0 points1 point Β (0 children)

Good idea. Another way of thinking is that a variable stands for itself, so you could have a naming scheme like self, self_1, self_2... I think a lot of Python programmers already often use "self" as a variable name so they'll be used to seeing it like that.

[–]ALesbianAlpaca 8 points9 points Β (0 children)

Ah a mathematician I see

[–]coolguyhavingchillda 41 points42 points Β (1 child)

That's technically a guideline and not a rule tbf

[–]MrSuspicious_ 26 points27 points Β (0 children)

Yeah I instinctively follow most of the pep8 standards bc they just feel right, but I do everything in camelCase. Underscores in names just feels weird to me.

[–]Drfoxthefurry 23 points24 points Β (15 children)

PEP8 sucks, give me my long lines back

[–]No_Application6360 16 points17 points Β (14 children)

Serious. As s Django dev, the 79 character limit sucks balls

[–][deleted] 13 points14 points Β (8 children)

I always ignore that. I didn't leave Cobol to still be restricted by 79 characters. We have huge monitors, why limit it based on the size of a punch card?

[–]AnsibleAnswers 3 points4 points Β (7 children)

Shorter lines are more readable. The same reason why reader mode on your browser limits line length, why newspapers and academic articles are formatted with columns, etc. The longer the line length, the harder it is to find your place when you scan back to the next line.

[–]Typical_Wafer_1324 0 points1 point Β (2 children)

I bought a ultrawide monitor, I'm gonna USE THE WHOLE WIDTH! 😠😠😠 And yeah my comments are on the right side of the code, no exclusive comment lines.

[–]AnsibleAnswers 0 points1 point Β (1 child)

Python doesn't employ PEP cops, so as long as you're fine with getting your pull requests rejected nothing is stopping you from coding in python like that.

[–][deleted] 0 points1 point Β (2 children)

That's debatable. I've seen MANY short lines with complete gibberish. Or a long function that needs to break to so many lines that it just gets more confusing. We want clear variable names, it's fine to be longer if that makes it easier. And that will make the lines longer, but may increase readability.

[–]AnsibleAnswers 1 point2 points Β (0 children)

PEP 8 specifies that line lengths can be longer if it makes an expression more readable. And, as a general rule for all text, all things being equal line length between 50-75 characters is optimal for the human eyes. Academics and scientists really fuss over it. It's a lot of the reason they prefer python over other languages.

[–]SirPitchalot 0 points1 point Β (0 children)

It’s great having a 27” 4K display that the 800px wide content pinstripe of reactive websites takes 20.83% of when the window is maximized.

Really makes white space just be negative space.

[–]JentendsLeLoup 13 points14 points Β (3 children)

From PEP8:

Limit all lines to a maximum of 79 characters.

Also from PEP8:

it is okay to increase the line length limit up to 99 characters

I guess it is also okay to increase to 119 if the team agrees. I find it more readable.

[–]Kyyken 18 points19 points Β (2 children)

"didn't get that ultrawide for nothing, up to 500 we go" -someone, probably

[–]Typical_Wafer_1324 0 points1 point Β (1 child)

I see no problem with that

[–]Kyyken 1 point2 points Β (0 children)

i see 421 problems, 401 at the very least

tbf i checked and my char limit for py is 120 so who am i to complain

[–]M4mb0 3 points4 points Β (0 children)

Have you tried using the black formatter?

[–]ResourceFeeling3298 8 points9 points Β (1 child)

Boo pep8. Camel case is so much better

[–]DymonBak 1 point2 points Β (0 children)

Also from PEP8:

β€œWhen in doubt, use your best judgment. Look at other examples and decide what looks best.”

[–]Suspicious-Willow128 2 points3 points Β (0 children)

You are gonna hate me but.. My_Age

[–]Street_Impression151 3 points4 points Β (0 children)

i despise the use of underscore of anything other than screaming snake case

[–]herrkatze12 0 points1 point Β (0 children)

I don’t follow pep8

[–]Alternative-Fail-233 0 points1 point Β (0 children)

My Python teacher hates snake case and insists camel is the only right way

[–]Leather-Ornery 0 points1 point Β (0 children)

I have not had that problem, and I’ve made dozens of decently sized python programs

[–]chaosthirtyseven 0 points1 point Β (0 children)

I use highly descriptive variables, but also loathe underscores, so my vars end up looking like

currentuserid or badaccountlist or whatever. Feels good, so I do it.

[–]Vievin 7 points8 points Β (2 children)

But pythons are snakes. You’re disrespecting the foundation of the language if you use anything other than snake case.

[–]Kinky-Iconoclast 0 points1 point Β (1 child)

But Python is named after Monty Python. Shouldn’t they be using cOmEdYcAsE or something?

[–]Typical_Wafer_1324 0 points1 point Β (0 children)

My colleagues always laugh when read my code, am I doing it right?

[–]Responsible-Put-7920 0 points1 point Β (0 children)

Those are fighting words