How to redirect Python’s sys.stdout to StringIO()

Run Ipython magic functions from your profile startup python script