python_api
python_api copied to clipboard
"return self" statements
The whole codebase contains tons of
return self
lines.
This is completely unpythonic and they do not make any sense. Just omit the 'return' statement completely..
+1 to this!
So a method with no return statement returns self by default? Ok.
A method with 'return' returns implicit None. There is no reason why a getter/setter should return anything at all - in particular why is should return 'self'. In addition: the typical getter/setter pattern of Java is pointless Python. Directly attribute assignment or access is what you want. If you need to massage a value upon get or set: use property()...but only if you really need it.