less hacky way of checking whether in iPython