NiceLabel.Blog Everything you wanted to know about NiceLabel

30Mar/11Off

Chaining comparison operators in Python

One of the little known facts about Python that can come handy is a possibility to chain comparison operators like this:

x = 5;
print 3 < x < 10;
print x < 10 < x*10;

or

x == y == z

or even

x is y is z
Comments (0) Trackbacks (0)

Sorry, the comment form is closed at this time.

Trackbacks are disabled.