Update Python coding guidelines authored by Moreau Nicolas's avatar Moreau Nicolas
......@@ -21,77 +21,76 @@ foo = long_function_name(var_one, var_two,
# Add 4 spaces (an extra level of indentation) to distinguish arguments from the rest.`
```def long_function_name(
```python
def long_function_name(
var_one, var_two, var_three,
var_four):
print(var_one)```
print(var_one)
`# Hanging indents should add a level.`
# Hanging indents should add a level.
`foo = long_function_name(`
foo = long_function_name(
` var_one, var_two,`
var_one, var_two,
` var_three, var_four)`
var_three, var_four)
```
Wrong:
```python
# Arguments on first line forbidden when not using vertical alignment.
`# Arguments on first line forbidden when not using vertical alignment.`
`foo = long_function_name(var_one, var_two,`
foo = long_function_name(var_one, var_two,
` var_three, var_four)`
var_three, var_four)
`# Further indentation required as indentation is not distinguishable.`
# Further indentation required as indentation is not distinguishable.
`def long_function_name(`
def long_function_name(
` var_one, var_two, var_three,`
var_one, var_two, var_three,
` var_four):`
var_four):
` print(var_one)`
print(var_one)
```
The 4-space rule is optional for continuation lines.
The closing brace/bracket/parenthesis on multiline constructs may either line up under the first non-whitespace character of the last line of list, as in:
`my_list = [`
` 1, 2, 3,`
` 4, 5, 6,`
` ]`
`result = some_function_that_takes_arguments(`
` 'a', 'b', 'c',`
` 'd', 'e', 'f',`
```python
my_list = [
1, 2, 3,
4, 5, 6,
]
```
` )`
```python
result = some_function_that_takes_arguments(
'a', 'b', 'c',
'd', 'e', 'f',
)
```
or it may be lined up under the first character of the line that starts the multiline construct, as in:
`my_list = [`
` 1, 2, 3,`
` 4, 5, 6,`
`]`
`result = some_function_that_takes_arguments(`
` 'a', 'b', 'c',`
` 'd', 'e', 'f',`
```python
my_list = [
1, 2, 3,
4, 5, 6,
]
```
`)`
```python
result = some_function_that_takes_arguments(
'a', 'b', 'c',
'd', 'e', 'f',
)
```
### Maximum Line Length
......
......