Changes
Page history
Update Python coding guidelines
authored
Oct 21, 2021
by
Moreau Nicolas
Show whitespace changes
Inline
Side-by-side
Python-coding-guidelines.md
View page @
e90952d7
...
...
@@ -316,15 +316,20 @@ Constants are usually defined on a module level and written in all capital lette
Correct:
`def f(x): return 2*x`
```
python
def
f
(
x
):
return
2
*
x
```
Wrong:
`f = lambda x: 2*x`
```
python
f
=
lambda
x
:
2
*
x
```
*
Use
<span
dir=
""
>
''.startswith()
</span>
and
<span
dir=
""
>
''
.endswith()
</span>
instead of string slicing to check for prefixes or suffixes.
*
Use
.startswith() and
.endswith() instead of string slicing to check for prefixes or suffixes.
*
Don't compare boolean values to True or False using == or is False/ is True
`# Correct:`
`if greeting:`
\ No newline at end of file
```
python
# Correct:
if
greeting
:
```
\ No newline at end of file