گاهی وقتا نمیخوای کد یه تابع رو تغییر بدی، ولی میخوای قبل یا بعد از اجرای اون تابع کاری انجام بدی، مثلاً زمان اجراش رو بسنجی، لاگ بگیری یا مجوز کاربر رو چک کنی.
اینجاست که Wrapper وارد میشه به این معنی که یه تابع که میاد یه تابع دیگه رو “میپیچه” و یه رفتار جدید بهش اضافه میکنه.
def wrapper(func): def inner(*args, **kwargs): print("🔹 Before execution") result = func(*args, **kwargs) print("✅ After execution") return result return inner
خروجی: 🔹 Before execution Hello Pythonista! ✅ After execution > درواقع Wrapper یه روکش برای تابع اصلیه که بدون تغییر در کد اصلی، یه رفتار جدید بهش اضافه میکنه.
گاهی وقتا نمیخوای کد یه تابع رو تغییر بدی، ولی میخوای قبل یا بعد از اجرای اون تابع کاری انجام بدی، مثلاً زمان اجراش رو بسنجی، لاگ بگیری یا مجوز کاربر رو چک کنی.
اینجاست که Wrapper وارد میشه به این معنی که یه تابع که میاد یه تابع دیگه رو “میپیچه” و یه رفتار جدید بهش اضافه میکنه.
def wrapper(func): def inner(*args, **kwargs): print("🔹 Before execution") result = func(*args, **kwargs) print("✅ After execution") return result return inner
خروجی: 🔹 Before execution Hello Pythonista! ✅ After execution > درواقع Wrapper یه روکش برای تابع اصلیه که بدون تغییر در کد اصلی، یه رفتار جدید بهش اضافه میکنه.
Hui said the time period and nature of some offences “overlapped” and thus their prison terms could be served concurrently. The judge ordered Ng to be jailed for a total of six years and six months. “[The defendant] could not shift his criminal liability,” Hui said. With the administration mulling over limiting access to doxxing groups, a prominent Telegram doxxing group apparently went on a "revenge spree." While some crypto traders move toward screaming as a coping mechanism, many mental health experts have argued that “scream therapy” is pseudoscience. Scientific research or no, it obviously feels good. In the next window, choose the type of your channel. If you want your channel to be public, you need to develop a link for it. In the screenshot below, it’s ”/catmarketing.” If your selected link is unavailable, you’ll need to suggest another option.
from us