Message226200
Just like for other binary operators (except for the ones mentioned as always needing spaces), the spaces around ":" are neither mandatory nor objectionable. I am not making up a new rule, this is how I've always thought -- we just have to make it explicit that x[1: n] is wrong.
How about this:
- However, in a slice the colon acts like a binary operator, and
should have equal amounts on either side (treating it as the
operator with the lowest priority). In an extended slice, both
colons must have the same amount of spacing applied. Exception:
when a slice parameter is omitted, the space is omitted. ::
Yes::
ham[1:9], ham[1:9:3], ham[:9:3], ham[1::3], ham[1:9:]
ham[lower:upper], ham[lower:upper:], ham[lower::step]
ham[lower+offset : upper+offset]
ham[: upper_fn(x) : step_fn(x)], ham[:: step_fn(x)]
ham[lower + offset : upper + offset]
No::
ham[lower + offset:upper + offset]
ham[1: 9], ham[1 :9], ham[1:9 :3]
ham[lower : : upper]
ham[ : upper] |
|
Date |
User |
Action |
Args |
2014-09-01 02:02:42 | gvanrossum | set | recipients:
+ gvanrossum, barry, ncoghlan, ezio.melotti, docs@python, Guido.van.Rossum, anthonymayer |
2014-09-01 02:02:42 | gvanrossum | set | messageid: <1409536962.32.0.625904829913.issue22316@psf.upfronthosting.co.za> |
2014-09-01 02:02:42 | gvanrossum | link | issue22316 messages |
2014-09-01 02:02:41 | gvanrossum | create | |
|