tags:

views:

3023

answers:

5

I have some Python code which I am finding difficult to read and I don't really want to learn the Python syntax if I can help it.

Can someone point me to a Python to C# converter?

+7  A: 

I'd rather suspect that such a tool doesn't exist. And if it did, it's output would be harder for a C# programmer to read than the input would be.


A better choice would be to uses IronPython to compile the Python and then use it from c#. if those guys did there job right, you should get all the intellisense you need to never look at the python. OTHO moding the code might be a pain.

BCS
+3  A: 

You can try to compile your python app using IronPython (http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython) to .NET, this should be possible without or just minor changes. This way you can make use of alle the .NET features from python.

Then you can decompile your IronPython assembly with an .NET decompiler like Lutz Roeders Reflector (http://www.red-gate.com/products/reflector) which can decompile whole Assemblies into Visual Studio projects. This way you can convert from ANY .NET Langauge into one of the supported languages of this program (C#.VB.NET,MC++,Delphi,Chrome)

codymanix
This is going to be AWFULLY difficult
Eric
+1 of answering the question -0.5 for a solution that's worse than the problem /j (but I round up today)
BCS
this technically works, although the resulting C# is incredibly unreadable because all operations and types are custom DLR classes and functions.
Jimmy
Though not clean, at least this is a real answer, unlike the "learn python" one.
boomhauer
+19  A: 

I would think in the time it takes you to figure out a way to do such a conversion with output that is actually useful, you could learn Python enough to follow the code. It has one of the simplest syntaxes of any language and some people even refer to it as "executable pseudo-code."

You might also learn something else along the way...

davidavr
+3  A: 

Thanks a lot for all the suggestions and comments guys! I think I'm just going to have bite the bullet and learn enough Python to get by ... yes it's part of being a programmer, and I know it should be fairly straightforward, but I wanted to just understand the code and not get distracted by the syntax ...

SuperHappyCoder
Could you update your question here when you've gone through? I'd like to hear how your experience went.
monkut
A: 

Unfortunately not in the direction you want, but there's a C# to Python converter on developer fusion that might help you learn the syntax?

James Crowley