[Python-ideas] Mutable default arguments - another approach

Piotr Duda duda.piotr at gmail.com
Tue Jan 30 19:18:46 CET 2007


2007/1/30, George Sakkis <george.sakkis at gmail.com>:
> On 1/30/07, Piotr Duda <duda.piotr at gmail.com> wrote:
>
> > I think that this problem can be solved by the following change of
> > default argument behavior:
> > default arguments are evaluated in definition time (like in current
> > implementation), but right after being evaluated, result object is
> > checked if it's mutable (for example by checking of presence __copy__
> > special method or being instance of built in (sub)class
> > list/dict/set)
> >
> > (snipped)
> >
>
> AFAIK there's no reliable way of deciding whether an arbitrary object
> is mutable or not, so the rest of the post is irrelevant. Besides,
> mutable default arguments is just a specific use case; the general
> problem discussed here is call-time vs definition-time semantics for
> arbitrary default argument expressions (function calls, attribute
> lookups, etc.).

AFAIK there's no reliable way of deciding whether an arbitrary object
has any feature (except it's type at c level), in worst case you can
treat all object as mutable, but that itself doesn't make rest of my
post irrelevant (have you even read it?).
Read my previous post again, and give me examples of what you cannot
do regarding default arguments.


-- 
闇に隠れた黒い力
弱い心を操る


More information about the Python-ideas mailing list