This is really rather simple, but I always have to figure it out every time I want to use it. It works somewhat like the C construct conditional ? value1 : value2. There are some conditions where it fails, so be careful where you use it. I will add some of these examples when I work them out.
In : v = 'NULL' In : isinstance(v, int) and v or 0 Out: 0 In : v = 22 In : isinstance(v, int) and v or 0 Out: 22