I am having trouble understanding the Dataset class. I understand the the magic methods__getitem__ and__len__ allow us to index and get the length of the Dataset object. However, I’m not sure how this is implemented.
I’ve tried to create a list for example:
ls = [1,2,38,9]
and then
l = Dataset(ls)
but I get
Traceback (most recent call last):
File “<pyshell#14>”, line 1, in
ls.Dataset()
AttributeError: ‘list’ object has no attribute ‘Dataset’
I have also tried
l = Dataset([1,2,6,7])
but get
Traceback (most recent call last):
File “<pyshell#20>”, line 1, in
l = Dataset([1,2,6,7])
TypeError: object() takes no parameters
Any help anyone could provide on how exactly this implementation works would be greatly appreciated.