ENع
الدرس 22 · Idiomatic Python

Decorators

لم يُترجم بعد؛ يُعرض باللغة الإنجليزية

A decorator is a function that takes a function and returns a new one, and @ is the shorthand that applies it. Step through a four-line decorator, shout, as Python hands greet to it, builds a wrapper that remembers the original in a closure, moves the name greet onto the wrapper, and turns 'hi sam' into HI SAM. Finish with functools.wraps, the one line every decorator should have.

14 دقيقة10 خطوات5 أسئلةBeginner
شكل 22 · تفاعلي
جارٍ تحميل الرسم…
أو ← →

اختبار يتاح بعد الخطوة الأخيرة.