[IPython-User] session settings

Matthias BUSSONNIER bussonniermatthias@gmail....
Fri Mar 29 13:53:35 CDT 2013


Hi Catherine, 

Here is ipynb that show how to do it through %config, 
Sorry for Brevity, and if it has been answered in the mean time,
I'm traveling and this will probably be send next time my computer will have a connection. 

Cheers, 
-- 
Matthias

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Configurable Magic.ipynb
Type: application/octet-stream
Size: 5459 bytes
Desc: not available
Url : http://mail.scipy.org/pipermail/ipython-user/attachments/20130329/94e2cda4/attachment-0001.obj 
-------------- next part --------------


Le 29 mars 2013 à 15:39, Catherine Devlin a écrit :

> Thanks, Matthias!  That's pretty much what I'm looking for, though I wish I could find a fully-functional example.  I managed to get it to where it can be configured via ipython_config.py, though not (?) by %config.  That will do for now, though.
> 
> 
> On Fri, Mar 29, 2013 at 4:58 AM, Matthias BUSSONNIER <bussonniermatthias@gmail.com> wrote:
> 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
> how.
> 
> 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.
> 
> -- 
> Matthias
> 
> 
> 
> 
> 
> 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
> 
> 
> _______________________________________________
> IPython-User mailing list
> IPython-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-user
> 
> 
> 
> 
> -- 
> - Catherine
> http://catherinedevlin.blogspot.com
> _______________________________________________
> IPython-User mailing list
> IPython-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-user



More information about the IPython-User mailing list