help explaining default function arg weirdness

John M. Gabriele john3gz at bestwebz.net
Mon Oct 11 21:01:53 CEST 2004


Robert Brewer wrote:
> John M. Gabriele wrote:
> 
>>What's the rationale for having the function remember
>>default_list across calls?
> 
> 
> http://www.python.org/doc/faq/general.html#why-are-default-values-shared
> -between-objects
> 
> The setting of default values is performed when the function is defined
> (only once), not when it is called (each time).
> 

Ah. Thanks Robert. I'm off to read the rest of that faq presently.

Looks like the rationale I was looking for is possibly not really
there, but rather, the behaviour is just a side-effect of how the
Python interpreter parses function definitions.

---J
-- 
--- remove zees if contacting via email ---



More information about the Python-list mailing list