Is torchvision.datasets.cifar.CIFAR10 a list or not?
When I try to figure out what is inside torchvision.datasets.cifar.CIFAR10, I did some simple code

trainset = torchvision.datasets.CIFAR10(root='./data', train=True,
                                    download=True, transform=transform)
print(trainset[1])
print(trainset[:10])
print(type(trainset))


However, I got some error when I try 

print(trainset[:10])


The error info is 

TypeError: Cannot handle this data type


I am wondering why I can use trainset[1], but not trainset[:10]?


Slicing isnt supported by CIFAR10, which is why you are getting that error. If you want the first 10 you will have to do this instead:
print([trainset[i] for i in range(10)])


More Info
The main reason why you can index an instance of CIFAR10 class is because the class implements __getitem__() function.
So, when you call trainset[i] you are essentially calling trainset.__getitem__(i)
Now, in python3, slicing expressions is also handled through __getitem__() where the slicing expression is passed to __getitem__() as a slice object.
So, trainset[2:10] is equivalent to trainset.__getitem__(slice(2, 10))
And since the two different types of objects being passed to __getitem__
are expected to do entirely different things, you have to handle them explicitly.
Unfortunately it isnt, as you can see from the __getitem__ method implementation of CIFAR10 class:
def __getitem__(self, index):
    if self.train:
        img, target = self.train_data[index], self.train_labels[index]
    else:
        img, target = self.test_data[index], self.test_labels[index]

    # doing this so that it is consistent with all other datasets
    # to return a PIL Image
    img = Image.fromarray(img)

    if self.transform is not None:
        img = self.transform(img)

    if self.target_transform is not None:
        target = self.target_transform(target)

    return img, target

