Sequence protocol

The sequence protocol requires that items can be retrieved using square brackets with an integer index:

item = sequence[index]

The items can be searched for with index():

i = sequence.index(item)

The items can be counted with count():

num = sequence.count(item)

They can be a reversed copy of the sequence can be produced with reversed():

r = reversed(sequence)

In addition, the sequence protocol requires that the object support the iterable, sized, and containers.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset