Unverified Commit 6b129c1d authored by Bertrand  NÉRON's avatar Bertrand NÉRON
Browse files

fix python 2 print

parent 48dbdd8d
Pipeline #58651 passed with stages
in 15 seconds
......@@ -28,11 +28,11 @@ help you by drawing diagram.
def func():
y = 5
print locals()
print(locals())
>>> func()
{'y': 5}
>>> print x
>>> print(x)
4
.. container:: clearer
......@@ -59,15 +59,15 @@ help you by drawing diagram.
def func():
y = 5
x = 8
print locals()
print(locals())
x = x + 2
>>> y = func()
{'y': 5, 'x': 8}
>>>
>>> print y
>>> print(y)
None
>>> print x
>>> print(x)
4
.. container:: clearer
......@@ -93,7 +93,7 @@ help you by drawing diagram.
def func(a):
y = x + 2
print locals()
print(locals())
x = y
return y
......@@ -134,7 +134,7 @@ help you by drawing diagram.
def func(a):
x = x + 2
print locals()
print(locals())
return x
y = func(x)
......@@ -171,9 +171,9 @@ help you by drawing diagram.
y = func(x)
>>> print x
>>> print(x)
4
>>> print y == x
>>> print(y == x)
False
.. container:: clearer
......@@ -200,11 +200,11 @@ help you by drawing diagram.
>>> x = 4
>>> z = func()
>>>
>>> print x
>>> print(x)
4
>>> print z
>>> print(z)
4
>>> print id(z) == id(x)
>>> print(id(z) == id(x))
True
.. container:: clearer
......@@ -225,15 +225,15 @@ help you by drawing diagram.
x = 4
def func(x = 5):
def func(x=5):
x = x + 2
return x
>>> y = func(x)
>>>
>>> print x
>>> print(x)
4
>>> print y
>>> print(y)
6
.. container:: clearer
......@@ -259,7 +259,7 @@ help you by drawing diagram.
def func(a):
global x
def func2():
print locals()
print(locals())
y = x + 4
return y
z = func2()
......@@ -267,9 +267,9 @@ help you by drawing diagram.
y = func(x)
{}
>>> print x
>>> print(x)
4
>>> print y
>>> print(y)
8
.. container:: clearer
......@@ -296,11 +296,11 @@ help you by drawing diagram.
y = func(x)
>>> print x
>>> print(x)
{'a': 4, 'b': 5}
>>> print y
{'a': 4, 'b': 5}
>>> print x is y
>>> print(x is y)
True
.. container:: clearer
......@@ -326,9 +326,9 @@ help you by drawing diagram.
y = func(x)
>>> print x
>>> print(x)
{'a': 4, 'b': 5}
>>> print y
>>> print(y)
None
.. container:: clearer
......@@ -398,7 +398,7 @@ help you by drawing diagram.
y = func(x)
print x
print(x)
{'a': 4, 'b': 6}
| in this code *func2* is executed
......@@ -433,7 +433,7 @@ help you by drawing diagram.
y = func(x)
print x
print(x)
{'a': 4, 'b': 5}
| in this code *x* a variable x is defined locally in *func2* and hide the global variable x
......@@ -444,7 +444,7 @@ help you by drawing diagram.
.. image :: _static/figs/spacer.png
Exercise
--------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment