diff --git a/IPython/Extensions/ipy_system_conf.py b/IPython/Extensions/ipy_system_conf.py new file mode 100644 index 0000000..42f86a3 --- /dev/null +++ b/IPython/Extensions/ipy_system_conf.py @@ -0,0 +1,19 @@ +""" System wide configuration file for IPython. + +This will be imported by ipython for all users. + +After this ipy_user_conf.py is imported, user specific configuration +should reside there. + + """ + +import IPython.ipapi as ip + +# add system wide configuration information, import extensions etc. here. +# nothing here is essential + +import sys + +if sys.version_info >= (2,4): + # rehashdir extension requires python 2.4 + import ext_rehashdir \ No newline at end of file diff --git a/IPython/UserConfig/ipy_user_conf.py b/IPython/UserConfig/ipy_user_conf.py new file mode 100644 index 0000000..e3fae60 --- /dev/null +++ b/IPython/UserConfig/ipy_user_conf.py @@ -0,0 +1,40 @@ +""" User configuration file for IPython + +This is a more flexible and safe way to configure ipython than *rc files +(ipythonrc, ipythonrc-pysh etc.) + +This file is always imported on ipython startup. You should import all the +ipython extensions you need here (see IPython/Extensions directory). + +""" + +# see IPython.ipapi for configuration tips + +import IPython.ipapi as ip + + +o = ip.options() +# autocall 1 ('smart') is default anyway, this is just an +# example on how to set an option +o.autocall = 1 + +if o.profile == 'pysh': + # Jason Orendorff's path class is handy to have in user namespace + # if you are doing shell-like stuff + ip.ex("from IPython.path import path" ) + +# get pysh-like prompt for all profiles. Comment these out for "old style" +# prompts, as determined by *rc files + +o.prompt_in1= '\C_LightBlue[\C_LightCyan\Y1\C_LightBlue]\C_Green|\#> ' +o.prompt_in2= '\C_Green|\C_LightGreen\D\C_Green> ' +o.prompt_out= '<\#> ' + +# make 'd' an alias for ls -F + +ip.magic('alias d ls -F --color=auto') + +# Make available all system commands. Comment out to speed up +# startup os slow machines and conserve a bit of memory + +ip.magic('rehashx') \ No newline at end of file diff --git a/IPython/ipapi.py b/IPython/ipapi.py index df22a7d..eeb317e 100644 --- a/IPython/ipapi.py +++ b/IPython/ipapi.py @@ -132,5 +132,12 @@ class ashook: def ex(cmd): - """ Execute a normal python statement """ - exec cmd in user_ns() \ No newline at end of file + """ Execute a normal python statement in user namespace """ + exec cmd in user_ns() + +def ev(expr): + """ Evaluate python expression expr in user namespace + + Returns the result """ + return eval(expr,user_ns()) + \ No newline at end of file diff --git a/IPython/ipmaker.py b/IPython/ipmaker.py index 9394fab..cfc63d7 100644 --- a/IPython/ipmaker.py +++ b/IPython/ipmaker.py @@ -6,7 +6,7 @@ Requires Python 2.1 or better. This file contains the main make_IPython() starter function. -$Id: ipmaker.py 1033 2006-01-20 10:41:20Z vivainio $""" +$Id: ipmaker.py 1037 2006-01-20 23:27:53Z vivainio $""" #***************************************************************************** # Copyright (C) 2001-2006 Fernando Perez. @@ -602,6 +602,14 @@ object? -> Details about 'object'. ?object also works, ?? prints more. else: IP.safe_execfile(os.path.expanduser(file),IP.user_ns) + # finally, try importing ipy_*_conf for final configuration + try: + import ipy_system_conf + import ipy_user_conf + + except ImportError: + IP.InteractiveTB() + # release stdout and stderr and save config log into a global summary msg.config.release_all() if IP_rc.messages: