[IPython-User] session settings

Matthias BUSSONNIER bussonniermatthias@gmail....
Fri Mar 29 03:58:29 CDT 2013

Hi Catherine, 

Magics are not the area where I am comfortable, but if I had to guess I would have said that those could be Configurable object.
Looking at the code it seem like they can be (IPython.core.magic:394) but they are not passed the config object.

Script magic go around by subclassing both Magics and Configurable (IPython.core.magics.script:74) and get config from `shell.config` L119 
so having IPython config files to set parameters, should work.

If magics inherit Configurable, I guess there would be a way to use also the %config magic to set parameters, but I'm not sure

You can append your magic class to shell.configurables in  __init__ , it does indeed do the trick and magics class will be listed  via %config once you do that… but  I can't figure out how to assign value as it does not seem to work.

I guess inspecting IPython.core.magic should help

Not sure if this was what you were hoping for.


Le 28 mars 2013 à 18:31, Catherine Devlin a écrit :

> Is there a recommended way for the user to set session-wide settings/variables?  I want to define something like
> In [27]: %agree
> Out[27]: u'Yes, of course!'
> In [28]: lang='japanese'
> In [29]: %agree
> Out[29]: 'Hai!'
> One way would be
> ip = IPython.core.ipapi.get()
> ip.user_ns['lang']
> But I don't know if the setting ``lang`` should necessarily take the form of a plain old variable in the user's namespace... really, I don't know what's the proper IPythonic way and how to do it.
> (really, I want to set a wrap/nowrap variable for %%sql, but that is more verbose to demonstrate)
> I realize this is probably in the docs somewhere, but I haven't been able to find it myself.  Thanks very much!
> -- 
> - Catherine
> http://catherinedevlin.blogspot.com
> PS https://github.com/catherinedevlin/ipython-sql getting very close to releasability!
> _______________________________________________
> IPython-User mailing list
> IPython-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-user

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-user/attachments/20130329/c36cddbe/attachment.html 

More information about the IPython-User mailing list