Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use Python alongside C# in Windows UWP app

I started writing an application in Python, but I now want to switch to C# and UWP. I know that you cannot write a UWP app in Python, but I am trying to see if I can write some code in Python and access that code from C#.

For example, writing a class in Python that C# code can access as well. Is that possible? And if so, can Python access Microsoft's UWP APIs?

The main code will not be written in Python; that would be impossible. But can interoperability between C# and Python exist, perhaps with IronPython (.NET's Python)?

And how would I set up such a Visual Studio project? I have Python Tools for Visual Studio installed, but there was no built-in option to add a Python file to my UWP app.

like image 590
M3579 Avatar asked Oct 31 '15 23:10

M3579


People also ask

How does Python work with C?

Python code can make calls directly into C modules. Those C modules can be either generic C libraries or libraries built specifically to work with Python. Cython generates the second kind of module: C libraries that talk to Python's internals, and that can be bundled with existing Python code.

Can C++ and Python work together?

Python Library is a open source framework for interfacing Python and C++. It allows you to quickly and seamlessly expose C++ classes functions and objects to Python, and vice-versa, using no special tools, just your C++ compiler.

Are Python libraries written in C?

Most of the Python Libraries are written in the C programming language. The Python standard library consists of more than 200 core modules. All these work together to make Python a high-level programming language.

Why is Cython faster?

Cython allows native C functions, which have less overhead than Python functions when they are called, and therefore execute faster.


1 Answers

'Classic' python interpreters in c# (as IronPython) don't work in store apps because of framework restrictions, as you run your app through a sandbox.

Some dude has ported the full python interpreter to WinRT on mercurial. Of course, due to framework restrictions, the whole standard library isn't available. This works with WinRT, so it will very likely work on UWP.

like image 84
Antoine C. Avatar answered Sep 21 '22 18:09

Antoine C.