In [1]:
import pocketnoobj
In [2]:
def m1(plist):
plist[0] /= 10
print("plist = ", plist)
plist = [10, 11, 12]
print("plist = ", plist)
In [3]:
ll = [1, 2, 3]
print("ll = ", ll)
In [4]:
ret = m1(ll)
In [5]:
print("ll = ", ll)
print("ret = ", ret)
In [6]:
print(id(ll))
In [1]:
%load_ext tutormagic
In [2]:
%%tutor
def m1(plist):
plist[0] /= 10
print("plist = ", plist)
plist = [10, 11, 12]
print("plist = ", plist)
ll = [1, 2, 3]
ret = m1(ll)
Opération de concaténation¶
In [9]:
def m2(plist):
print(id(plist))
plist = plist + [4] # variable local = paramètre + [4]
print(id(plist))
return plist
In [10]:
ret = m2(ll)
print("ll = ", ll)
print("ret = ", ret)
In [11]:
%%tutor
def m2(plist):
print(id(plist))
plist = plist + [4] # variable local = paramètre + [4]
print(id(plist))
return plist
ret = m2(ll)
Opération de concaténation en place¶
In [12]:
def m3(plist):
print(id(plist))
plist += [5]
print(id(plist))
In [13]:
print(id(ll))
ret = m3(ll)
print("ll = ", ll)
print("ret = ", ret)
In [14]:
%%tutor
def m3(plist):
print(id(plist))
plist += [5]
print(id(plist))
ret = m3(ll)
In [15]:
def m4(plist):
print(id(plist))
append(plist, 6)
print(id(plist))
In [16]:
print(id(ll))
ret = m4(ll)
print("ll = ", ll)
print("ret = ", ret)
In [17]:
%%tutor
def m4(plist):
print(id(plist))
append(plist, 6)
print(id(plist))
ret = m4(ll)