Steven D'Aprano <steve+pyt...@pearwood.info> added the comment:
Hi Jacob, and welcome. You said: "I was experimenting with nested dictionaries when I came across strange behavior that I can not figure out at all." This is a bug tracker, for reporting bugs, not a help desk for asking how to figure out Python's behaviour. Python is 30 years old and what you are calling "strange" has exactly how Python has worked for all that time. Sorry to tell you, but it is your understanding that is lacking, not a bug in the language. I can't really tell why you think it is "strange" -- I've been using Python for 20 years or so, and I'm not sure what you think is weird about this, it all seems perfectly natural to me. I'm having difficulty in seeing why you expect something different, sorry. This bug tracker is not the right place to get into a long discussion about Python's behaviour. There are plenty of other places, like the Python-List mailing list, or StackOverflow, or Reddit's r/learnpython. But I *guess* that maybe you expect that when you call your function input_into_nested_dict(m, y, 'hello') that the dict `m` is copied before being passed to the function? If that's what you think is happening, let me assure you that no it is not. Python never copies data structures unless you explicitly tell it to, and specifically assignment does not make copies either. So when you say `cdip = dictionary`, that doesn't make a copy of the input dict, it is just a new name for the original global dict. These may help you: https://nedbatchelder.com/text/names1.html https://www.youtube.com/watch?v=_AEJHKGk9ns Good luck! ---------- nosy: +steven.daprano resolution: -> not a bug stage: -> resolved status: open -> closed _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue40639> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com