[IPython-User] session settings
Fri Mar 29 03:58:29 CDT 2013
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 : %agree
> Out: u'Yes, of course!'
> In : lang='japanese'
> In : %agree
> Out: 'Hai!'
> One way would be
> ip = IPython.core.ipapi.get()
> 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
> PS https://github.com/catherinedevlin/ipython-sql getting very close to releasability!
> IPython-User mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the IPython-User