I need to check a variable, called status, of an object in python. What I am doing is the known:
if p.status() in range(21,30):
where p is my object. I need to check if this status is between -21 and -29, but it only works if I write the range in positive numbers instead of negative. When I wrote:
if p.status() in range(-30,-21):
it didn’t return anything. (Of course I printed the status of this object and I am sure that this condition exist). Some ideas???
Thanks
Forget
range. Chained comparison operators are much more readable.By the way, the
stopargument ofrangeis never included in the return value, so for -21 to -29 inlusive, you’d wantrange(-29,-20).