+ 2

how to create a destructor of a class?

29th Oct 2016, 12:28 AM
Shekhar Bahuguna
Shekhar Bahuguna - avatar
4 odpowiedzi
+ 5
class FooType(object): def __init__(self, id): self.id = id print self.id, 'born' def __del__(self): print self.id, 'died' f= FooType(2) 2, born 2, died
29th Oct 2016, 12:34 AM
Shekhar Bahuguna
Shekhar Bahuguna - avatar
0
Why does 'born' here not need parentheses?
5th Nov 2016, 3:18 PM
Yves Guillaume A. Messy
Yves Guillaume A. Messy - avatar
0
Yves: you indeed need parentheses after print at least on QPython 3 for Android... and I guess in Python 3.x in general.
26th Jan 2017, 12:27 AM
Didier Baudewyns
Didier Baudewyns - avatar
0
Yeah QPython is based on Python 3.3 as far as I know.
16th Feb 2017, 6:23 AM
Sungmin Woo
Sungmin Woo - avatar