Optional parameter object re-used when instantiating multiple objects

Chris Rebert clp at rebertia.com
Fri Nov 21 08:25:31 CET 2008


On Thu, Nov 20, 2008 at 9:26 PM, alex23 <wuwei23 at gmail.com> wrote:
> On Nov 21, 10:07 am, Aaron Brady <castiro... at gmail.com> wrote:
>> Why, I would expect the interpreter to define the functions when it
>> first hits the def, that is, at the point of definition.
>
> Then why are you arguing that the parameters should be re-defined at
> the point of calling?

I would assume because using the "def is start of definition" theory,
anything after the "def" is part of the function definition/body and
should not be immediately executed, but rather be executed at
call-time. The function body comes after the "def" and doesn't get run
immediately, so neither should the default argument values.

I take no position on the virtue of said theory.

Cheers,
Chris
-- 
Follow the path of the Iguana...
http://rebertia.com

>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list