Don't build strings like
def greet(name):
return "Hello " + name
Use f-strings:
def greet(name):
return f"Hello {name}"
They are both more readable and more efficient.
Drop all the to-string-like methods. They are very uninteresting and unrealistic: there's no way an object would take care of its actual representation. For example, what about localization?
MI is too advanced a concept.
- Access control: how to make members private/protected in python
- Properties (getters, setters)
- Static methods
- Abstract methods using abc module
Never use assert
to validate input.
Do not check parameter types. Python encourages duck typing, not nominal typing.
- Have them write their own tests
- Have them find bugs in given code
- Have them refactor a complex function (rename variables, divide into functions)
- Improve efficiency