[Python-Dev] PEP 231, __findattr__()

Martin v. Loewis martin@loewis.home.cs.tu-berlin.de
Sun, 3 Dec 2000 22:56:44 +0100


> Isn't there a way to accomplish the desired effect without modifying
> the instance? In the context of __findattr__, *we* know that we
> don't want to get a recursive call.  Let's assume __getattr__ and
> __setattr__ had yet another optional parameter: infindattr,
> defaulting to 0.  We would than have to pass a positive value in
> this context, which would object.c tell to not try to invoke
> __findattr__ again.

Who is "we" here? The Python code implementing __findattr__? How would
it pass a value to __setattr__? It doesn't call __setattr__, instead
it has "self.__myfoo = x"...

I agree that the current implementation is not thread-safe. To solve
that, you'd need to associate with each instance not a single
"infindattr" attribute, but a whole set of them - one per "thread of
execution" (which would be a thread-id in most threading systems). Of
course, that would need some cooperation from the any thread scheme
(including uthreads), which would need to provide an identification
for a "calling context".

Regards,
Martin