
On 1/30/07, Roman Susi <rnd@onego.ru> wrote:
George Sakkis wrote:
On 1/30/07, Piotr Duda <duda.piotr@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.).
George
Maybe Python interpreter could be better at deciding if the programmer which wrote the code is novice or experienced.
For example,
from __present__ import _I_AM_PYTHON_EXPERT
at the beginning of each module will do ;-)
That would be a good start, but certainly not the end; how about programmers who *read* other people's code ? Their experience level may well be quite different, and the code should be understandable by these poor souls too. The python source files would have to be able to sense when they're being read or printed, determine the experience level of the reader and transform themselves to accomodate his level. Anyone wanna write the PEP for Python-7000 ? ;-) George