Is An Element of a Sequence an Object?
Jon Forrest
nobozo at gmail.com
Sun Jun 4 00:17:55 EDT 2017
On 6/3/2017 4:58 PM, Chris Angelico wrote:
> A sequence doesn't necessarily "contain" anything.
Maybe not always, but doesn't
"abc"
contain three characters? Is 'contain' the right word?
> As has been mentioned, a range object is a sequence, but it creates integer
> objects lazily.
So there must be a class of sequence, like a literal string, that
contains multiple characters stored as one object, and another
class, like range(500000), that doesn't store anything, and only
produces values when it's iterated over. Plus, a list is a sequence,
but in this case it's clear that each element of a list is an object.
Jon
More information about the Python-list
mailing list