Home c# Using Python 3 with C #

Using Python 3 with C #

Author

Date

Category

Hello!

Is it possible to integrate Python 3 and C #?

There is an application on C # in which I want to make a scripting functionality in mind Python 3 scripts. It would be especially good if Python was compiled in MSIL and could use CLR assemblies, but, as I understood, IronPython supports only 2.7.

If it is impossible, are there any other scripted languages, well integrated with CLR (not only at the Interop level)?


Answer 1, Authority 100%

In IronPython, I wanted to add support for Python 3, but Microsoft stopped supporting development, and the main development went to another company. Since the teams are no longer, it is actively developing the IronPython no one. Ironpython and IronRuby are designed at the expense of Microsoft, then they have an interest in the DLR, and they threw the code into Open-Sort. The last time I looked, the branch for the third python was sluggishly developed. It is so, historical reference.

And now to the case. What is not satisfied with Python 2.7? If Unicode, then in IronPython all lines and so unicode.

If you want a close connection with .NET, then this is one of the best options. The relationship with .NET is full and very detailed.

In general, for .NET are implemented many languages, including Ruby, JavaScript and others. But choose them due to the fact that Python does not need the version you will be, at least, strange. In the near future, the 2.x branch will live. And alternative implementations for the .NET still will not sleep for the latest novelties of languages, no matter how language you choose.

I can understand if you already have a layer of code on Python 3 or the urgent need for new features of the third version of the language. But in the conditions when the application simply needs to add scripts, oriented stands to several other parameters: how much the language is distributed, as far as the interoperability is realized.


Answer 2, Authority 40%

about other languages.

  1. PowerShell. Script language that originally works in CLR. From here – transparent work with any objects.

  2. C # itself. The command line mode, of course, is not supported – but the script is in the file, can be compiled on the fly and execute.


Answer 3

found IronPython for Raspiton. Last Commit 3 months ago

You can also use the 3TO2 (in order to convert Python 3 code into Python 2 code ) and use a stable official version:

$ PIP Install 3TO2
$ 3TO2 manifest_parser.py -w
... the output is omitted ...
$ Python2.
Python 2.7.6 (Default, Mar 22 2014, 22:59:38)
[GCC 4.8.2] ON Linux2
Type "Help", "Copyright", "Credits" or "License" for more information.
... Import Manifest_Parser.

And no exceptions


Answer 4

Another option:

Use a separate application on C # and a separate process on python, communication – via SOAP or XML-RPC. Queries and answers can be driven by stdin / stdout, you can via HTTP, you can via MQ …

The advantage of this method is a priori opportunity to use the version of the language that seems most beautiful.


Answer 5

and another communication option. You can make the main application on python, and portion on C # do as a library. The module for CPYthon can be easily written on C++ / CLI.

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions