Appearance
Python
Testing
assertAlmostEqualis good to use for microsecond assertions- test should test for what does and should happen in the logic, avoid testing that something does not happen
Methods
- aim to have either
TrueorFalseexplicitly returned
General
- make use of try/excepts more often so that errors can be more properly handled
- raise errors instead of returning responses with error data
- use
.setover.bulk_create
Internal Methods and Variables
Some variables are functions will begin with an underscore (_function). This is to indicate that the method or variable is internal to a class or module. The following is an example of what this looks like
python
def my_method(self, param1, param2, **kwargs):
def _internal_method(_param1, _param2):
non_param_variable = False # if a variable is within the internal method we do not need to underscore it
for _item in _param1 # if we are looping through an internal param, the loop variable should be underscored
print(_item)
_param2 = True