On 07/05/15 21:54, Jim Mooney Py3.4.3winXP wrote:
Ah, thanks. I forgot small integers are saved in a table. I was looking at a demo that pointers to defaults in function parameters are persistent.
But remember they variables are NOT pointers. They are keys in a dictionary. Very different. Also the id() function is implementation dependant so although it may seem to be a memory address in CPython it is something else in IronPython and something else again in Jython. The only thing guaranteed is that it is a unique id for that object. As to default parameter values, the default object is persistent but if you reassign the parameter inside the function it will obviously lose its binding to the default object. It will only be reassigned to it on the next function call (unless it's a generator function). -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor