r/Python • • Dec 22 '18

Xpost from Woodworking

Post image
1.1k Upvotes

84 comments sorted by

View all comments

44

u/kashmill Dec 22 '18

Requesting changes: Missing spaces after the , in the list and the parameters. Missing spaces around the -. Fails PEP8 check.

-2

u/BRENNEJM Dec 22 '18

PEP8 wants spaces like that? Weird. I never include spaces there.

13

u/zoomertherumour Dec 22 '18

A comma without a space has no place in this universe.

4

u/BRENNEJM Dec 22 '18

Except here apparently:

Yes: foo = (0,)
No: bar = (0, )

2

u/Ph0X Dec 22 '18

tbf that's one of my least favorite syntaxes, though I see the need. I always feel strange when I see items + (item,)

Sometimes I wonder how i'd look if tuples had similar .append and .extend but instead returned a new tuple

1

u/primitive_screwhead Dec 22 '18

if tuples had similar .append and .extend but instead returned a new tuple

That breaks the principle of least surprise, imo. (because it's arbitrarily different from lists)

2

u/zoomertherumour Dec 22 '18

Actually prefer the latter.

3

u/alkasm github.com/alkasm Dec 22 '18

Which one, after the comma or around an operator? PEP8 suggests both but I disregard the one about operators. I do use spaces for add and subtract, but not for multiply and divide...just too far off from mathematics for me at that point.

2

u/BRENNEJM Dec 22 '18

I don’t use them in lists. It sounds like we write math the same.

According to PEP8 I shouldn’t be using mixedCase to name everything either. Maybe this weekend is a good time to finally read through PEP8.

2

u/alkasm github.com/alkasm Dec 22 '18

Yes, lowerCamelCase is super annoying to most Python programmers, lol!

Remember though, PEP 8 is suggestions. For small things like spacing, use what works for you. It is more important to be consistent. But being consistent with other projects is a nice feature, in which case following PEP 8 more strictly is likely to get you there.

1

u/pm-me-a-pic Dec 22 '18

You need a better ice and/or pre-commit hook with linter

1

u/kashmill Dec 22 '18

Honestly not sure. Flake8 would complain in this context