[Tutor] How to verify all things are equal to one another
Terry Carroll
carroll at tjc.com
Sun May 15 07:54:53 CEST 2005
Suppose I have several variables, e.g.: a, b, c, d, e, f, g.
I would like to be able to see if they're all the same, I don't care what
the value is, as long as they're equal. If they're all equal to 0, or to
"spam", or to ["cleese", "idle", "gilliam"], as long as they're the same.
Is there a more pythonic way of doing this other than,
if (a == b &
a == c &
a == d &
a == e &
a == f &
a == g):
do stuff
For example, is there any kind of function:
if allsame(a, b, c, d, e, f, g):
do stuff
I can roll my own, but I was just wondering if something already existed
like this.
More information about the Tutor
mailing list