+ 1

Is it must to create a __init__ method in a class?

Assigning property by __init__ is quite convinient, but just to check the compulsion of having a __init__ method, i tried this one: http://www.sololearn.com/app/JUMP_LINK__&&__python__&&__JUMP_LINK/playground/chC0rWvmtmgS/

8th Oct 2016, 3:15 PM
Rohit Kumar
2 Antworten
+ 1
no it's not necessary class A(object): def f(): print 'foo' a =A() a.f()
29th Oct 2016, 12:38 AM
Shekhar Bahuguna
Shekhar Bahuguna - avatar
0
its not a must
9th Oct 2016, 1:00 PM
Calvin Ochieng
Calvin Ochieng - avatar