Class Encapsulation Errors in Python 2.3.3

Duncan Booth duncan.booth at suttoncourtenay.org.uk
Fri Nov 19 16:57:58 CET 2004


> On 19 Nov 2004 10:44:56 GMT, Duncan Booth <duncan.booth at invalid.invalid>
> wrote: > Jeff Shannon wrote: > > > The problem here is that default values
> in functions/methods are > > evaluated at *compile* time. > > Actually,
> no. The default values in functions/methods are evaluated when > the def
> statement is *executed* not when anything is compiled. If you > execute
> the def multiple times the default values are recalculated each > time.
> 
> Be careful :-) default values are calculated when the def statement is
> executed.... which is not the same as to say that they are calculated
> every time the function is called.
> 
<rest of explanation snipped>

I actually thought I had stated the case fairly clearly, but I 
suppose understanding what you think you have said isn't the same as 
communicating it to the audience. :)


-- 
Duncan Booth
duncan.booth at suttoncourtenay.org.uk





More information about the Python-list mailing list