0
Whats wrong with writing it like this?
class X : def __init__(self): self.a = [] self.b = [] self.c = [] Should it instead be: class X : def __init__(self, a, b, c): self.a = [] self.b = [] self.c = [] ???
3 Answers
+ 1
It won't work like this.
You should initialize a class first unless.
In your case, try
x = X()
x.a.append(something)
0
The first one takes no arguments when initialize an instance X while the second one needs a, b, c.
If not, the second one will raise errors. Which one to use depends on your practical situations.
0
Yuming Chen
In this case :
class X :
def __init__(self):
self.a = []
self.b = []
self.c = []
If i want to append to a, does X.a.append() work?