This is my code:
def toto(liste=[]):
print(id(liste))
liste.append("coucou")
print(id(liste))
return liste
print(toto())
print(toto())
print(toto([]))
print(toto([]))
And the result in the console:
63335800
63335800
['coucou']
63335800
63335800
['coucou', 'coucou']
60547280
60547280
['coucou']
60547280
60547280
['coucou']
Why this difference? Why does Python use the same object as a local variable (same identifier) and why don't we get the same result depending on whether or not we put the empty list as an input parameter?