2021年4月3日星期六

Why is there no Iterable in the bases of the range class but its object is Iterable instance?

If the object is an instance of a class, then the class should be found in the inheritance relationship of the class.

I didn't find it.

Is my understanding wrong?

rangeObject = range(3)  rangeClass = type(rangeObject)  class range(unittest.TestCase):      def test_bases_of_range(self):          self.assertEqual(rangeClass.__bases__,(object,))      def test_range_instance(self):          self.assertIsInstance(rangeObject,collections.Iterable)  
https://stackoverflow.com/questions/66937439/why-is-there-no-iterable-in-the-bases-of-the-range-class-but-its-object-is-itera April 04, 2021 at 10:06AM

没有评论:

发表评论