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 942157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:13:39+00:00 2026-05-15T22:13:39+00:00

In Python, the built-in functions all and any return True and False respectively for

  • 0

In Python, the built-in functions all and any return True and False respectively for empty iterables. I realise that if it were the other way around, this question could still be asked. But I’d like to know why that specific behaviour was chosen. Was it arbitrary, ie. could it just as easily have been the other way, or is there an underlying reason?

(The reason I ask is simply because I never remember which is which, and if I knew the rationale behind it then I might. Also, curiosity.)

  • 1 1 Answer
  • 1 View
  • 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-05-15T22:13:39+00:00Added an answer on May 15, 2026 at 10:13 pm

    How about some analogies…

    You have a sock drawer, but it is currently empty. Does it contain any black sock? No – you don’t have any socks at all so you certainly don’t have a black one. Clearly any([]) must return false – if it returned true this would be counter-intuitive.

    The case for all([]) is slightly more difficult. See the Wikipedia article on vacuous truth. Another analogy: If there are no people in a room then everyone in that room can speak French.

    Mathematically all([]) can be written:

    where the set A is empty.

    There is considerable debate about whether vacuous statements should be considered true or not, but from a logical viewpoint it makes the most sense:

    The main argument that all vacuously true statements are true is as follows: As explained in the article on logical conditionals, the axioms of propositional logic entail that if P is false, then P => Q is true. That is, if we accept those axioms, we must accept that vacuously true statements are indeed true.

    Also from the article:

    There seems to be no direct reason to pick true; it’s just that things blow up in our face if we don’t.

    Defining a “vacuously true” statement to return false in Python would violate the principle of least astonishment.

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

Sidebar

Related Questions

Are there built in functions in Clojure similar to Python's any and all functions?
Many of Python's built-in functions ( any() , all() , sum() to name some)
Wrote the following two functions for storing and retrieving any Python (built-in or user-defined)
The Python 2 documentation says: Built-in Functions: map(function, iterable, ...) Apply function to every
All the Python built-ins are subclasses of object and I come across many user-defined
I'm wondering if there's a reason that there's no first(iterable) in the Python built-in
Does Python have a built-in, simple way of encoding/decoding strings using a password? Something
There are so many html and xml libraries built into python , that it's
I do like the way I can treat lists in Python. It does any
In Python's interactive shell you can get a list of built-in functions (if you

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.