标签: python python-3.x
可以实现方法__str__(self)来返回字符串。是否有__list__(self)个对应方? (__list__无效!) 是.toList()的方法吗?
__str__(self)
__list__(self)
__list__
答案 0 :(得分:15)
没有直接的对应物,但list()是通过迭代参数来实现的。因此,请实施the iterator protocol(__iter__())或bound indexing(__len__()和__getitem__())。
list()
__iter__()
__len__()
__getitem__()