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

  • Home
  • SEARCH
  • 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 9023487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:46:22+00:00 2026-06-16T05:46:22+00:00

I would’ve expected Python’s keys method to return a set instead of a list.

  • 0

I would’ve expected Python’s keys method to return a set instead of a list. Since it most closely resembles the kind of guarantees that keys of a hashmap would give. Specifically, they are unique and not sorted, like a set. However, this method returns a list:

>>> d = {}
>>> d.keys().__class__
<type 'list'>

Is this just a mistake in the Python API or is there some other reason I am missing?

  • 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-16T05:46:23+00:00Added an answer on June 16, 2026 at 5:46 am

    One reason is that dict.keys() predates the introduction of sets into the language.

    Note that the return type of dict.keys() has changed in Python 3: the function now returns a "set-like" view rather than a list.

    For set-like views, all of the operations defined for the abstract base class collections.abc.Set are available (for example, ==, <, or ^).

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

Sidebar

Related Questions

Would be possible to extend this kind of layout so that I can have
Would like to know how to install libsvm for python under windows 7? I
Would anyone be kind enough to explain to me what I'm doing wrong. I'm
Would it work to use Expression<Func<T>> or Func<T> as keys in a dictionary? For
Would you know if something similar to Terracotta (in Java world) exists for Python
would you create 3 list(of coordinate) for empty position black position white position or
Would it have been bad if, instead of synchronized keyword we had @Synchronized annotation?
Would encrypting the S3 keys in my binary be a good idea? How? Thanks!
Would NSSortDescriptor subclasses be placed in the Model or the Controller layer? Since they
Would the most efficient way-and I know it's not very efficient, but I honestly

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.