Run Code  | API  | Code Wall  | Users  | Misc  | Feedback  | Login  | Theme  | Privacy  | Patreon 

Интересный Python - Вопрос 1

Language: Layout:
+ ] Show input
Absolute running time: 0.41 sec, cpu time: 0.16 sec, memory peak: 6 Mb, absolute service time: 0,41 sec 
edit mode |  history  | discussion
look carefully for object identities

define Inner

define Outer
Inner.__init__( <__main__.Inner object at 0x7fdecd8a54a8> )

create OuterInstanceA
Outer.__init__( <__main__.Outer object at 0x7fdecc31e780> )
Inner.__init__( <__main__.Inner object at 0x7fdecc31e7b8> )

create OuterInstanceB
Outer.__init__( <__main__.Outer object at 0x7fdecc31e828> )
Inner.__init__( <__main__.Inner object at 0x7fdecc31e860> )

OuterInstanceA.class_attribute :: <__main__.Inner object at 0x7fdecd8a54a8>
OuterInstanceA.instance_attribute :: <__main__.Inner object at 0x7fdecc31e7b8>
OuterInstanceB.class_attribute :: <__main__.Inner object at 0x7fdecd8a54a8>
OuterInstanceB.instance_attribute :: <__main__.Inner object at 0x7fdecc31e860>
Outer.class_attribute :: <__main__.Inner object at 0x7fdecd8a54a8>
Outer.instance_attribute ! type object 'Outer' has no attribute 'instance_attribute'

delete OuterInstanceA
Outer.__del__( <__main__.Outer object at 0x7fdecc31e780> )
Inner.__del__( <__main__.Inner object at 0x7fdecc31e7b8> )

delete OuterInstanceB
Outer.__del__( <__main__.Outer object at 0x7fdecc31e828> )
Inner.__del__( <__main__.Inner object at 0x7fdecc31e860> )

delete Outer

end
Inner.__del__( <__main__.Inner object at 0x7fdecd8a54a8> )