3 ms·
This was discussed pretty recently in this thread on "Python Newbie Mistakes, Part 1". Default values for functions in Python are instantiated when the functio
by jliechti1 13y ago
This was discussed pretty recently in this thread on "Python Newbie Mistakes, Part 1".
Default values for functions in Python are instantiated when the function is defined, not when it’s called.
Thread: https://news.ycombinator.com/item?id=5999772 https://news.ycombinator.com/item?id=5999772
Direct link: http://blog.amir.rachum.com/post/54770419679/python-common-newbie-mistakes-part-1 http://blog.amir.rachum.com/post/54770419679/python-common-n...
It looks like the author posted a "part 2" to HN as well, but it never made the front page.
http://blog.amir.rachum.com/post/55024295793/python-common-newbie-mistakes-part-2 http://blog.amir.rachum.com/post/55024295793/python-common-n...