+ 1

Take a look! What is the effect of the code "list.__init__([ ])"?

class Mylist(list): def __init__(self,a_name): list.__init__([ ]) self.name=a_name

6th Nov 2017, 8:25 AM
Southlittle
Southlittle - avatar
5 odpowiedzi
+ 7
It lets you initialize a variable, with the initialized variable having a value of an empty list
6th Nov 2017, 9:06 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 2
@James I mean even though there is no "list.__init__([ ])", I am still able to use methods like append,extend...etc
6th Nov 2017, 2:00 PM
Southlittle
Southlittle - avatar
+ 1
@Pegasus but if I delete that line of the code, it make no difference when I give it to a variable.
6th Nov 2017, 9:16 AM
Southlittle
Southlittle - avatar
+ 1
I am still not clear about that.
6th Nov 2017, 9:17 AM
Southlittle
Southlittle - avatar
+ 1
@James Could you explain that to me?
6th Nov 2017, 2:02 PM
Southlittle
Southlittle - avatar