+ 1

Why print statement in __init__ not executing first?

class A: def __init__(self,a): self.a=a print("in init") print("in A") o=A(30) o/p. In A In init

13th Nov 2020, 6:24 PM
Subhash
Subhash - avatar
5 ответов
+ 4
Because print("in A") comes before you instantiated the class. Though you indented it under the class doesn't mean it has something to do with class, it's a statement on it's own.
13th Nov 2020, 7:38 PM
Divine Darkey
Divine Darkey - avatar
+ 3
You're Welcome.
15th Nov 2020, 12:46 AM
Divine Darkey
Divine Darkey - avatar
+ 2
hannah simth, I'm thinking you've used the search feature and you've found an answer right? You're Welcome.
17th Nov 2020, 11:33 AM
Divine Darkey
Divine Darkey - avatar
0
Thank you
14th Nov 2020, 6:21 PM
Subhash
Subhash - avatar
0
thanks you
16th Nov 2020, 10:57 PM
hannah simth