implement 'switch' in python