<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Apr 18, 2015 at 2:23 PM, Steven D'Aprano <span dir="ltr"><<a href="mailto:steve@pearwood.info" target="_blank">steve@pearwood.info</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Are you sure this doesn't already work? It works for me in Python 3.3:</blockquote></div><br><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">It doesn't really work because of the incomplete checks done in `callable_builtin`. ​This is what I've tried:<br><br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><span style="font-family:monospace,monospace">>>> class DynamicCallable:<br>...     is_callable = True<br>...<br>...     def __init__(self, target):<br>...         self.target = target<br>...<br>...     @property<br>...     def __call__(self):<br>...         if self.is_callable:<br>...             return self.target<br>...         else:<br>...             raise AttributeError("Not really ...")<br>...<br>>>> dc = DynamicCallable(print)<br>>>> dc(1, 2, 3)<br>1 2 3<br>>>> callable(dc)<br>True<br>>>> dc.is_callable = False<br>>>> callable(dc)<br>True ###### This should be False :(<br></span></blockquote><div><br></div><div>If the "bug" is fixed, then the last thing in the above example would return False.<br></div></div><span style="font-family:monospace,monospace"></span><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div><span style="font-family:trebuchet ms,sans-serif"><span style="color:rgb(51,51,51)"><br><font size="2"><span style="color:rgb(51,51,51)">Thanks,</span><br><span style="color:rgb(153,153,153)">-- Ionel</span></font></span><font size="2"><font style="color:rgb(153,153,153)"> Cristian Mărieș, <a href="http://blog.ionelmc.ro" target="_blank">http://blog.ionelmc.ro</a><br></font></font></span></div></div></div></div></div></div></div>
</div></div>