1

In Python 2.7 the code is something like:

res=[ f(x) for x in some_list]
def f(x, d={})
    d['changing d']=5

Now see that d is not given and so should get an empty dictionary as its default value. But when f() is called for the second time, d looks like d from the previous call of f(). In other words: When f() is called in the second time - initially inside f() d has the value {'changing d':5} and is not an empty dictionary.

Does d became global? Please advice

user2986978
  • 153
  • 1
  • 5

0 Answers0