Steh grad auf dem Schlauch und bekomm den Fuß nicht hoch. :K
Könnte mir bitte jmd. erklären wieso im Folgenden a nicht verändert werden kann?
Also nach Ausführen der Funktion fill(a), a immernoch ein leeres Dictionary ist?
Code: Alles auswählen
Python 3.4.5 |Continuum Analytics, Inc.| (default, Jul 5 2016, 14:53:07) [MSC v.1600 64 bit (AMD64)
] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> a = {}
>>> def fill(recipient):
... recipient = {'test':1}
...
>>> a
{}
>>> fill(a)
>>> a
{}
>>> def fill2(recipient):
... recipient = 1
...
>>> a
{}
>>> fill2(a)
>>> a
{}
>>> def fill3(recipient):
... print(id(recipient))
...
>>> id(a)
34636936
>>> fill3(a)
34636936
>>>