On 2015-02-18 02:14, candide wrote:
Le mercredi 18 février 2015 01:50:16 UTC+1, Chris Angelico a écrit :

So, what's a container? It's a thing that you put other objects
into.

I agree with this approach. The important point to consider here is
the last word in your definition : "into". There is the container and
there is the content (the objects into). The so-called built-in
containers (list, string, etc) are in conformance with this view.
Now, regarding a range object as a container disagrees completely
with the definition given in the PLR : there is no contents and hence
there is no container. For instance, range(10**6) doesn't hold any
kind of object, there are no reference to the int objects 0, 1, 2,
... As the range's docstring explains, range returns a VIRTUAL
sequence.

It's a virtual, read-only container that contains integers.

Try comparing range(10) with tuple(range(10)). Both contain integers.
Both have a length. Both can be indexed.
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to