Building on top of Python in Maya #1: Decorators because
- Context managers and decorators are similar. They both allow for easy reuse of wrapping code (runs before and after any other code)
- Reusing and improving the code examples
- A decorator is used in this post: https://docs.python.org/3/library/contextlib.html#contextlib.contextmanager
- Only use current_unit?
- Generalize current_unit to any command?
- Decorator with argument examples?
- Name working_units or current_unit?
- Procedural programming paradigm is the "opposite", by extracting/reusing the middle code section (vs. the wrapping part)
- The ContextDecorator can be used as decorator and context manager: https://docs.python.org/3/library/contextlib.html#contextlib.ContextDecorator