forked from openedx/edx-platform
-
Notifications
You must be signed in to change notification settings - Fork 18
collections multiline
stv edited this page Jul 12, 2018
·
1 revision
- Define collections (lists, dictionaries, sets) with one item per line
- Indent lines by one level
- don't align with the opening symbol:
(
/[
/{
- don't align with the opening symbol:
words = [
'foo',
'bar',
]
words = ['foo', 'bar',]
words = ['foo',
'bar',]
Multiline collections are easier to manage (insert/remove) when each item is on its own line.
This also reduces long lines, making the code easier to read.
Consider:
'foo',
- 'bar',
]
'bar',
+ 'baz',
]
versus:
- words = ['foo', 'bar',]
+ words = ['foo',]
- words = ['foo', 'bar',]
+ words = ['foo', 'bar', 'baz',]
External Resources: