<div dir="ltr">Yes, I understand that, but I don't see how that would help at all with annotations. Aren't annotations also evaluated at "compile time"?</div><br><div class="gmail_quote"><div dir="ltr">On Tue, Sep 27, 2016 at 8:14 AM Oleg Broytman <<a href="mailto:phd@phdru.name">phd@phdru.name</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Tue, Sep 27, 2016 at 11:54:40AM +0000, Neil Girdhar <<a href="mailto:mistersheik@gmail.com" target="_blank">mistersheik@gmail.com</a>> wrote:<br>
> I don't understand why that would work and this clearly doesn't?<br>
><br>
> Mutual2 = "Mutual2" # Pre-declare Mutual2<br>
><br>
> class Mutual1:<br>
> def spam(self, x=Mutual2):<br>
^^^^^^^ - calculated at compile time,<br>
not at run time<br>
> print(type(x))<br>
><br>
> class Mutual2:<br>
> def spam(self):<br>
> pass<br>
><br>
> Mutual1().spam()<br>
><br>
> prints class "str" rather than "type".<br>
<br>
Try this:<br>
<br>
class Mutual1:<br>
def spam(self, x=None):<br>
if x is None:<br>
x = Mutual2<br>
print(type(x))<br>
<br>
class Mutual2:<br>
def spam(self):<br>
pass<br>
<br>
Mutual1().spam()<br>
<br>
Oleg.<br>
--<br>
Oleg Broytman <a href="http://phdru.name/" rel="noreferrer" target="_blank">http://phdru.name/</a> <a href="mailto:phd@phdru.name" target="_blank">phd@phdru.name</a><br>
Programmers don't die, they just GOSUB without RETURN.<br>
</blockquote></div>