bind
bind

Reputation: 13

Tuple Equivalence in python

  1. What is the definition of tuple equivalence in python?
  2. If two tuples have the same element regardless of order, are they equivalent tuples?

I looked in python documentation on tuples equivalence, however, it was not very clear description. http://docs.python.org/2/tutorial/datastructures.html

Upvotes: 1

Views: 6059

Answers (2)

wRAR
wRAR

Reputation: 25559

Such things are defined in the language reference, not in the tutorial.

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.

Upvotes: 10

unutbu
unutbu

Reputation: 880627

Two tuples are equal if the items in the tuples taken in order are equal.

Upvotes: 6

Related Questions