micropython

tests/attributes_shadowing.py

230:892b13f1cba4
2009-05-30 Paul Boddie Changed instantiator invocation reserving a frame slot regardless of whether the target is known in advance. In the instantiator, the first frame slot is then overwritten with the new instance, and the RecoverFrame instruction is no longer required. Instead, a new JumpInFrame instruction maintains the existing locals, jumping to the initialiser method for the class. Updated various tests, renaming and enhancing the classes test.
     1 #!/usr/bin/env python     2      3 class C:     4     clsattr = 123     5      6     def __init__(self, value=None):     7         self.instattr = value is None and self.clsattr or value      8      9 c1 = C(789)    10 c2 = C()    11 result_789 = c1.instattr    12 result_123 = c2.instattr    13     14 # vim: tabstop=4 expandtab shiftwidth=4