ENع
الدرس 12 · Collections and functions

Scope

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

Where can a name be used? Python keeps names in namespaces: one global namespace for the whole file, and a fresh local namespace every time a function is called. Step through a seven-line program, scope.py, and watch a function read a global name, make its own local one, hand a value back with return, and then forget its local names, so asking for one afterwards stops the program with a NameError.

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

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