Skip to content
4 changes: 3 additions & 1 deletion Doc/library/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1736,7 +1736,9 @@ are always available. They are listed here in alphabetical order.
Rather than being a function, :class:`range` is actually an immutable
sequence type, as documented in :ref:`typesseq-range` and :ref:`typesseq`.


The object returned by :class:`range` is an :term:`iterator` and supports iteration.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not totally correct to say "the object returned by range", because range itself is the object. Instead, we should say something like "the range type is an iterator".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your feedback and corrections!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or along the lines of "an instance of range is an iterator"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That works too.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn’t correct - range isn’t an iterator, it’s a sequence (though it is iterable). Note how you can iterate the same range object multiple times, and next() fails. There’s a separate range_iterator type, like list_iterator etc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, yeah. Let's just say "range supports iteration" or something like that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have update with this
The :class:range type is iterable and supports iteration.

Please let me know , if this needs further improvement .

See also :ref:`iterator` for more information about iterators and how to implement
custom iterable classes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a lot of iterators throughout the documentation, but this makes it seem like range is special. I think we should remove this note -- the iterator term already contains lots of information about iterators.

.. function:: repr(object)

Return a string containing a printable representation of an object. For many
Expand Down