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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:25:48+00:00 2026-06-02T19:25:48+00:00

So i know that comparisons on tuples work lexicographically: Tuples and lists are compared

  • 0

So i know that comparisons on tuples work lexicographically:

Tuples and lists are compared lexicographically using comparison of corresponding elements. This means that to compare equal, each element must compare equal and the two sequences must be of the same type and have the same length.

If not equal, the sequences are ordered the same as their first differing elements. For example, cmp([1,2,x], [1,2,y]) returns the same as cmp(x,y). If the corresponding element does not exist, the shorter sequence is ordered first (for example, [1,2] < [1,2,3]).

So from this:

>>> a = (100, 0)
>>> b = (50, 50)
>>> a > b
True

But i want to compare all elements of 2 tuples in order, so functionally i want something akin to (using values from above):

>>> a > b
(True, False) #returned tuple containing each comparison
>>> all(a > b)
False

As an example in practice, for something like screen coordinates, if you wanted to check if something was ‘inside’ the screen at (0,0), but done a comparison like coord > (0,0), if the x coord was bigger than 0, but the y coord was smaller it would still return true, which isn’t what is needed in this case.

As sort of a sub question/discussion:
I am not sure why comparing 2 tuples of different values is returned in such a way. You are not given any sort of index, so the only thing you get from comparing a tuple (that isn’t testing equality) is that at some point in the tuple, one of the comparisons will throw a true or false value when they are not equal. How could you take advantage of that?

  • 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-02T19:25:49+00:00Added an answer on June 2, 2026 at 7:25 pm

    You can achieve this with a list comprehension and the zip built-in:

    >>> a = (100, 0)
    >>> b = (50, 50)
    >>> [(a > b) for a, b in zip(a,b)]
    [True, False]
    

    You can use all() or any() on the returned list.

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

Sidebar

Related Questions

I know that this has already been asked here but the answer (using a
Does anyone know of a diff viewer or comparison program that can do paragraph-based
I know that I should put all the html elements in body tag, but
I know that it's possible to implicitly provide asynchronous interaction using: Asynchronous Delegates Asynchronous
I’ve been playing around with searching text in big lists and found that using
I know that for instance, using: if (in_array('...'), array('.', '..', '...') === true) Over:
I know that this must be quite a basic use case, but I don't
I know that you can use the ctypes library to perform case insensitive comparisons
I know this isn't that big a deal since it's still fast (thanks to
I know that in C, for if statements and comparisons FALSE = 0 and

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.