__call__ considered harmful or indispensable?
bruno.42.desthuilliers at wtf.websiteburo.oops.com
Fri Aug 3 10:01:06 CEST 2007
Skip Montanaro a écrit :
>>> In this case there was a bug. Depending on inputs, sometimes obj
>>> initialized to a class, sometimes an instance of that class. (I fixed
>>> that too while I was at it.) The problem was that the use of __call__
>>> obscured the underlying bug by making the instance as well as the class
>> I don't quite get the point here. A concrete example would be welcome.
> The bug went something like this:
> obj = some.default_class
> if some_other_rare_condition_met:
> ... several lines ...
> obj = some.other_class()
> x = obj()
Ok, I see. A nasty one, indeed.
More information about the Python-list