2020-10-19 21:08:55

This commit is contained in:
wizardforcel
2020-10-19 21:08:55 +08:00
parent 7f63048035
commit ab0caba1f0
140 changed files with 3982 additions and 3982 deletions

View File

@@ -13,7 +13,7 @@
In [1]:
```
```py
def foo(a,b):
c = 1
d = a + b + c
@@ -26,7 +26,7 @@ def foo(a,b):
In [2]:
```
```py
c = 1
def foo(a,b):
d = a + b + c
@@ -41,7 +41,7 @@ def foo(a,b):
In [3]:
```
```py
c = 1
def foo():
global c
@@ -53,7 +53,7 @@ print c
```
```
```py
1
2
@@ -65,7 +65,7 @@ print c
In [4]:
```
```py
c = 1
def foo():
c = 2
@@ -76,7 +76,7 @@ print c
```
```
```py
1
1
@@ -86,7 +86,7 @@ print c
In [5]:
```
```py
def list_length(a):
return len(a)
@@ -95,7 +95,7 @@ print list_length(a)
```
```
```py
3
```
@@ -104,7 +104,7 @@ print list_length(a)
In [6]:
```
```py
import __builtin__
__builtin__.len
@@ -113,7 +113,7 @@ __builtin__.len
Out[6]:
```
```py
<function len>
```
@@ -128,7 +128,7 @@ Out[6]:
In [7]:
```
```py
# global
var = 0
@@ -162,7 +162,7 @@ class MyClass(object):
In [8]:
```
```py
obj = MyClass()
```
@@ -180,12 +180,12 @@ obj = MyClass()
In [9]:
```
```py
obj.access_class_c()
```
```
```py
class var: 1
```
@@ -203,12 +203,12 @@ class var: 1
In [10]:
```
```py
obj.access_global_c()
```
```
```py
global var: 0
```
@@ -226,12 +226,12 @@ global var: 0
In [11]:
```
```py
obj.write_class_c()
```
```
```py
class var: 2
```
@@ -249,26 +249,26 @@ class var: 2
In [12]:
```
```py
obj.write_instance_c()
```
```
```py
instance var: 3
```
In [13]:
```
```py
MyClass.var
```
Out[13]:
```
```py
2
```
@@ -280,7 +280,7 @@ Out[13]:
In [14]:
```
```py
def outer():
a = 1
def inner():
@@ -291,7 +291,7 @@ outer()
```
```
```py
a = 1
```
@@ -302,7 +302,7 @@ a = 1
In [15]:
```
```py
def outer():
a = 1
def inner():
@@ -315,7 +315,7 @@ print 'a (1):', func()
```
```
```py
a (1): 1
```