[Tutor] Surprising behaviour of optional argument

Alan Gauld alan.gauld at btinternet.com
Fri Jul 18 00:05:00 CEST 2014


On 17/07/14 23:00, Jose Amoreira wrote:

> Aha, the object that stores the default value for the optional argument
> is created at the time of the execution of the function definition and
> mutable objects do mutate, so that's that. It makes a lot of sense.

Yes, think of it as a feature, not a bug :-)


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos



More information about the Tutor mailing list