Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8634601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:45:53+00:00 2026-06-12T09:45:53+00:00

What methods must be implemented in a class definition so that it can be

  • 0

What methods must be implemented in a class definition so that it can be considered as a sequence type and an iterable type? And if there’s a formal definition for them can you also provide a reference to PEP or another document where it is defined?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T09:45:54+00:00Added an answer on June 12, 2026 at 9:45 am

    From the glossary:

    An iterable is:

    A object with an __iter__() or __getitem__() method. Examples of
    iterables include all sequence types (such as list, str, and tuple)
    and some non-sequence types like dict and file. When an iterable
    object is passed as an argument to the builtin function iter(), it
    returns an iterator for the object. This iterator is good for one pass
    over the set of values.

    An iterator is:

    An iterable which has a next() method. Iterators are required to have
    an __iter__() method that returns the iterator object itself. An
    iterator is good for one pass over the set of values.

    A sequence is:

    An iterable which supports efficient element access using integer
    indices via the __getitem__() special method and defines a len()
    method that returns the length of the sequence. Some built-in sequence
    types are list, str, tuple, and unicode. Note that dict also supports
    __getitem__() and __len__(), but is considered a mapping rather
    than a sequence because the lookups use arbitrary immutable keys
    rather than integers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a coding standard that says all shared (static) fields and methods must
In struts2 upload methods, can I choose where the uploaded file must be saved.
I've implemented a class that looks like this interface: [ImmutableObject(true)] public interface ICustomEvent {
In the Activity class, Android provides runtime enforcement that super() must be called for
For example, I have a class that has two strings, one of which must
I must be missing something obvious about how the various Scanner methods work but
I realize that the method run() must be declared because its declared in the
Suppose I have a method that must return an object (say from a database
I'm just to figure out what does this method do, I know there must
Methods marked as virtual can be overridden in derived classes. One of the restrictions

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.