no way to compare when less than two revisions

تفاوت‌ها

تفاوت دو نسخهٔ متفاوت از صفحه را مشاهده می‌کنید.


courseware:python_programming:resources:code:16 [2022/07/19 17:51] (فعلی) – ایجاد شد - ویرایش خارجی 127.0.0.1
خط 1: خط 1:
 +===== اسکوپ‌ها در پایتون و ترتیب اولویت آن‌ها =====
  
 +اولویت و ترتیب اسکوپ‌ها: Local, Enclosing, Global, Built-in
 +
 +<code python line-numbers="true">
 +x = 'global x'
 +def outer():
 +    x = 'enclosing x'
 +    
 +    def inner():
 +        x = 'local x'
 +        print(x)
 +
 +    inner()
 +    print(x)
 +
 +outer()
 +print(x)
 +
 +def max(a):
 +    return sum(a)
 +
 +# global max
 +max([1, 2, 3])
 +</code>