yapf icon indicating copy to clipboard operation
yapf copied to clipboard

Spaces is slice operator

Open kotofos opened this issue 10 years ago • 2 comments

Isn't this code from readme contradict pip8 about spaces around the slice operator? def f(a): return 37 + -+a[42 - x:y ** 3]

exactly: https://www.python.org/dev/peps/pep-0008/#pet-peeves Item 3:

No: ham[lower + offset:upper + offset]

kotofos avatar Jul 17 '15 06:07 kotofos

Yeah. I noticed this before. I super disagree with it, but it's not my PEP document. :-) There are a few formatting decisions that conflict here. But I think we can implement something that may help here...

bwendling avatar Jul 27 '15 07:07 bwendling

Spaces in the context of slicing can lead to confusion or readability issues but typically do not cause functional errors in Python. The key is to ensure that colons are used correctly and consistently in slice operations to avoid any syntax errors or misunderstandings.

janhavi-naik14 avatar May 25 '24 15:05 janhavi-naik14