[Python.NET] announcement - IPython cell magic for C# usage in jupyter notebooks (clrmagic)

Denis Akhiyarov <[email protected]>
Newsgroups gmane.comp.python.dotnet
Message-ID <CALxxJLTOKe3_7kramfkpEQB5sN9BCbYZUNLUZ3UBWiZOUXSPVQ@mail.gmail.com>
Last week I noticed very useful blog post on how to use C# magic cells with
pythonnet from IPython by Xavier Dupré @sdpython
<https://github.com/sdpython>:

http://www.xavierdupre.fr/blog/2014-09-20_nojs.html

As a result of this, we put together a package clrmagic
<https://pypi.python.org/pypi/clrmagic> that can be installed and loaded
into jupyter notebooks in 3 steps:

*pip install clrmagic*

*jupyter notebook*

In open notebook enter:

*%reload_ext clrmagic*

Here is a small demo:

%%CS mypower System.dll
public static double mypower(double x, double y)
{
    if (y == 0) return 1.0 ;
    return System.Math.Pow(x,y) ;
}

<function clrmagic.create_cs_function.<locals>.<lambda>>

mypower(3.0,3.0)

27.0

Note that clrmagic works and is tested both on Windows and Linux! It should
also work on OSX, but I have not tested.

Currently the source code is hosted here:

https://github.com/denfromufa/clrmagic

I plan to host this code in pythonnet repository under:

https://github.com/pythonnet/clrmagic

Let's wait for one week to get any feedback from this mailing list and
jupyter group (to be posted later this week).

Thanks,

Denis and Xavier

_________________________________________________
Python.NET mailing list - [email protected]
https://mail.python.org/mailman/listinfo/pythondotnet
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.