Hi Nat,
Thank you very much for your reply. I am sorry if I did not explain
something clearly.
The output file I am generating is as Test.DLL only. I am not generating it
as .pyd.
This DLL has a class called MyClass. In it, I have add, sub, mul n div.
I am doing as below after implementing the MyClass in the same file:
BOOST_PYTHON_MODULE(hello){
class_<MyClass>("MyClass")
.def("add",&MyClass::add);
}
I am using CDLL from ctypes to load this Test.DLL. Say
planet = CDLL("Test.DLL").
Now I want to create an object of MyClass and call add function. How can I
do this?
Regards,
Raju.
On Wed, Jun 6, 2012 at 4:20 PM, Nat Linden <[email protected]> wrote:
> On Wed, Jun 6, 2012 at 5:09 AM, Nagaraju <[email protected]>
> wrote:
>
> > I wrote a wrapper class in the same file as BOOST_PYTHON_MODULE(hello).
> >
> > Now when I compiled this DLL, I get Test.DLL.
>
> Hmm, the module thinks its name is "hello", but it's in Test.DLL?
> Maybe it should be hello.pyd?
>
> The .pyd is to designate it as a Python extension. Python stopped
> importing plain .dlls along about Python 2.5.
>
> > Now from Python, I wrote a script to load this Test.DLL.
>
> As 'import Test' or as 'import hello'?
>
> > How can I access add, sub and other functions in my Python script?
>
> You said you wrote a wrapper class, and that the add, sub etc. are
> methods on that class?
>
> Let's say your wrapper class is called Wrapper.
>
> import hello
> obj = hello.Wrapper() # instantiate
>
> -- or, equivalently --
>
> from hello import Wrapper
> obj = Wrapper()
>
> -- then, either way --
>
> print obj.add(something, something_else)
> _______________________________________________
> Cplusplus-sig mailing list
> [email protected]
> http://mail.python.org/mailman/listinfo/cplusplus-sig
>
_______________________________________________
Cplusplus-sig mailing list
[email protected]
http://mail.python.org/mailman/listinfo/cplusplus-sig