def list_all_same_type(type_conv): def conv(v): return [conv(i) for i in v] if isinstance(v, list) else type_conv(v) return conv