sorin
sorin

Reputation: 170400

How to add implicit imports to ipython?

I am using a the PYTHONSTARTUP=~/pythonstartup.py approach in order to make ipython the default python shell but I want to extend it do have some additional imports by default (like importing few common packages).

How can I do that?

#!/usr/bin/env python
import os
import sys
import re
import time
import platform
import IPython

os.environ['PYTHONSTARTUP'] = ''  # Prevent running this again
IPython.start_ipython()
raise SystemExit

Upvotes: 2

Views: 41

Answers (1)

sorin
sorin

Reputation: 170400

Problem solved by adding

IPython.start_ipython(user_ns=locals())

Upvotes: 2

Related Questions