ENع
الدرس 18 · Objects

Inheritance

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

A class can be built on top of another one. Write class Dog(Animal) and every Dog can use what Animal defines, while Dog adds or replaces only what is different. Step through a ten-line program, pets.py, and watch where Python finds each attribute: __init__ comes from Animal, name lives on the object itself, and Dog's own speak wins over Animal's. That fixed search order is the method resolution order (MRO), and super() lets an override call the parent's version.

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

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