Reputation: 1273
I have 2 function that use the same variable, like this:
some_function():
#do something with MyDict
MyDict = dict()
MyDict['name'] = 'hallo'
main():
#do something else with MyDict
MyDict['age'] = 33
some_function()
I don't want to use global
and let say that MyDict
is very big and I don't want to pass it to some_function
. what is the best way to do so? there is a way to pass a pointer to MyDict
?
PS: I'm using py3.2
Upvotes: 0
Views: 136
Reputation: 18851
In short: when you pass a dict
as argument to a function, only the reference is passed, the data is not copied.
However, in general the parameters are references but some types are mutables but others aren't which changes the behavior.
Upvotes: 1