[IPython-User] session settings

MinRK benjaminrk@gmail....
Fri Mar 29 12:32:16 CDT 2013


On Thu, Mar 28, 2013 at 10:31 AM, Catherine Devlin <
catherine.devlin@gmail.com> wrote:

> 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']
>

Don't use `core.ipapi.get`, this has been deprecated since 0.11 (I don't
think it ever wasn't deprecated, I don't know why it is still there).
Use `get_ipython()`.


>
> 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!
>

It may not be.  You can define other magics that set attributes on your
Magics class, as illustrated [here](http://nbviewer.ipython.org/5272287)


>
> --
> - 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/43ac2041/attachment.html 


More information about the IPython-User mailing list