How to implement Python Decorators

Python decorators a nice way to implement the decorator pattern. Perhaps you read the article about Python data classes and wondered how the @dataclass thingy worked. Let’s say we created the following function: def un_decorated_function(): print(‘–> Starting un_decorated_function’) print(‘Inside un_decorated_function’) print(‘<– un_decorated_function finished’) We can use a decorator to log entry and exit of a…

How to structure your Python project

This is not a “my way or the highway” kind of advice. Just a bunch of good practices. A starting point if you are new to Python. You will likely inspect and adapt your own project structure over time. The bare minimum This is a setup I recommend when just want to start with a…