For this, I would like to use CPython API functions such as
Py_Initialize, PyModule_New, PyModule_GetDict, PyRun_String,
PyObject_GetAttrString, PyObject_CallObject, PyTuple_SetItem & other
similar functions from my C#/ VC++ program on Windows.
I have installed Python251.msi on my Desktop.
Can I start doing the development using the include, lib & the
python25.dll files availale after installing this MSI?
Yes. You don't require the source package to embed Python and use the API
in your programs.
--
Gabriel Genellina
Does it mean, I can embed Python in C# as well with the same APIs?
> On Dec 7, 12:17 pm, "Gabriel Genellina" <gagsl-...@yahoo.com.ar>
> wrote:
>> En Thu, 06 Dec 2007 23:27:15 -0300, grbgooglefan <ganeshbo...@gmail.com>
>> escribió:
>>
>> > I want to use Python's Windows (python25.dll) version to embed in my
>> > C# (or atleast VC++) program for performing syntax checks on the
>> > Python expressions which are later supposed to be evaluated at runtime
>> > by another C++ program [...]> Can I start doing the development using
>> the include, lib & the
>> > python25.dll files availale after installing this MSI?
>>
>> Yes. You don't require the source package to embed Python and use the
>> API in your programs.
>
> Does it mean, I can embed Python in C# as well with the same APIs?
No; you can use the Python API in a native C++ application (the Python
code is plain C, but all the include files have the 'extern "C" {}'
declarations). For .NET there are IronPython and PythonNet, but I cannot
comment on them, surely someone else may help. See
http://www.python.org/about/
--
Gabriel Genellina
Hello, Anybody else out there has used Python from C#?
Yes. I use Python for .Net to embed python code in my applications,
and it works pretty well.
It's not a matter of C++ or C## but a matter of managed or unmanaged
language. Nowadays VS C++ can create old style binaries and CLR. For C++
you can use the MSI but I recommend a source installation. It makes
debugging easier. You may want to port my PCbuild9 directory from svn
trunk (Python 2.6) to Python 2.5 if you like to use VS 2008.
For CLR/.NET (Managed C++, C#, VB, ...) you need the PythonDotNET
bindings from http://pythonnet.sf.net/. Brian (the creator of
PythonDotNET) and I are very busy in the last weeks and months. The last
preview release is outdated. Please check out the latest version from
PythonDotNET's SVN.
The support for unmanaged C++ is better than the support for managed
.NET code.
Christian
It's not a matter of C++ or C## but a matter of managed or unmanaged
> > Does it mean, I can embed Python in C# as well with the same APIs?
>
> No; you can use the Python API in a native C++ application (the Python
> code is plain C, but all the include files have the 'extern "C" {}'
> declarations). For .NET there are IronPython and PythonNet, but I cannot
> comment on them, surely someone else may help. See http://www.python.org/about/
The answer is YES. C# can access C functions exported by any DLL with
platform invoke. Since the Python C API is plain C and not C++ you can
gain access to it from C#. Import System.Runtime.InteropServices and
write wrappers like
[DllImport("Python25.dll"), CallingConvention=CallingConvention.Cdecl]
public static void Py_Initialize();
etc.
You can also combine C++ and C# in a project in MS Visual Studio, if
you prefer to access Python from C++. That way you don't have to write
platform invoke wrappers for the Python C API.
There is no need for that. PythonDotNET wraps the P/Invokes and internal
C API of CPython in a nice .NET API.
Christian
There is no need for that. PythonDotNET wraps the P/Invokes and internal