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"?
On Tue, Sep 27, 2016 at 8:14 AM Oleg Broytman
On Tue, Sep 27, 2016 at 11:54:40AM +0000, Neil Girdhar < mistersheik@gmail.com> wrote:
I don't understand why that would work and this clearly doesn't?
Mutual2 = "Mutual2" # Pre-declare Mutual2
class Mutual1: def spam(self, x=Mutual2): ^^^^^^^ - calculated at compile time, not at run time print(type(x))
class Mutual2: def spam(self): pass
Mutual1().spam()
prints class "str" rather than "type".
Try this:
class Mutual1: def spam(self, x=None): if x is None: x = Mutual2 print(type(x))
class Mutual2: def spam(self): pass
Mutual1().spam()
Oleg. -- Oleg Broytman http://phdru.name/ phd@phdru.name Programmers don't die, they just GOSUB without RETURN.