On Wed, May 23, 2012 at 11:25 AM, Marcin Tustin <span dir="ltr">&lt;<a href="mailto:marcin.tustin@gmail.com" target="_blank">marcin.tustin@gmail.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Python 2.7.2<div class="HOEnZb"><div class="h5"><br><br><div class="gmail_quote">On Wed, May 23, 2012 at 4:23 PM, PJ Eby <span dir="ltr">&lt;<a href="mailto:pje@telecommunity.com" target="_blank">pje@telecommunity.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><p><br>
On May 23, 2012 10:39 AM, &quot;Marcin Tustin&quot; &lt;<a href="mailto:marcin.tustin@gmail.com" target="_blank">marcin.tustin@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt; I&#39;ve found that instances of ObjectWrapper (and any subclasses) are always callable (the callable function returns True), notwithstanding that the __subject__ is not callable. Is there a way to remedy this?<br>
&gt;<br>
&gt; I&#39;ve tried deleting the __call__ method, creating empty slots, creating my own call method, then trying to delete, using del or delattr on the subclass object, and creating a custom __getattribute__, all to no avail. </p>



</div><p>Which Python version are you using?</p>
</blockquote></div><br></div></div></blockquote></div>Okay, I&#39;ve verified that this happens all the way back to 2.3, so that&#39;s not it.  (I think that maybe Python 3 uses hasattr(__call__) as its callable() implementation, but I&#39;m not sure.)<br>
<br>It looks like the only way for me to fix this is with a major revision: change the base classes to not have a __call__ slot, and dynamically change type at runtime to a subclass with a __call__ slot, if and only if their subject is callable...  and to somehow change if the subject changes.  (Not really sure how that&#39;s going to work.)<br>
<br>What&#39;s the use case for this?  What code is using callable(), and can you convince its author to use hasattr instead?  ;-)<br><br><br>