Python for Data Engineers: Using Function Decorators
HTML-код
- Опубликовано: 14 июн 2023
- Function decorators are like inheritance for Python functions. They let you easily add functionality to existing functions without changing the decorated function. And they are used in many popular Python frameworks including Django, Flask, and even Databricks. Learn what decorators are, how to use them, and how to write your own!
Patreon Community and Watch this Video without Ads!
www.patreon.com/bePatron?u=63...
Demo Jupyter Notebook available at:
github.com/bcafferky/shared/b... Наука
Great and super useful series! Appreciate it so much as a DE beginner, looking forward to the next one.
A must for me to check. I'm trying to grasp usage of functools in decorators.
Do you have a playlist for python for data engineering?
Just started it here ruclips.net/p/PL7_h0bRfL52qOdwqGlXd9nN4J0sauPssL
Superb ! Thanks ! One question...Even if I comment out the @wraps, it is working the same..Can you please explain the wraps ?
@lru_cache is the one I’m most familiar with. Does the decorator have to be on it’s own line or can I just search and replace def with @decorator def. Similar to how Java annotations can be on the same line as the thing they are annotating.
Not sure but I would strongly recommend putting the decorator on its own line. It's more readable and therefore more Pythonic. Mushing lines together is a bad idea and I still have nightmares of the old BASIC program days when lines were all crammed together. :-)