Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #68288
| From | Stefan Behnel <stefan_ml@behnel.de> |
|---|---|
| Subject | Re: How to create an instance of a python class from C++ |
| Date | 2014-03-12 18:10 +0100 |
| References | <0ab424e9-3a3f-4111-9f41-ff50ce73d70d@googlegroups.com> <8AEE6BCA-0F61-4F9E-A18B-13DB283DC134@barrys-emacs.org> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.8096.1394644216.18130.python-list@python.org> (permalink) |
Barry Scott, 11.03.2014 22:37:
> On 5 Mar 2014, at 00:14, Bill wrote:
>> I can't figure out how to create an instance
>> of a python class from 'C++':
>
> Why not use pycxx from http://sourceforge.net/projects/cxx/?
>
> This lib does all the heavy lifting for you for both python2 and python3.
> Has docs and examples.
Yes, tool support definitely helps here. I was going to suggest Cython
(also for obvious reasons), where the code that the OP posted would look
like this:
def RegisterClass(class_decl):
an = type(class_decl)()
print(an.description())
return 0
Clearly substantially simpler than the posted C code (and certainly safer,
faster and more correct) - although that doesn't really help me much with
understanding what the intention of this code is, looks rather weird...
Stefan
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
How to create an instance of a python class from C++ Bill <galaxyblue63@gmail.com> - 2014-03-04 16:14 -0800
Re: How to create an instance of a python class from C++ Ian Kelly <ian.g.kelly@gmail.com> - 2014-03-04 18:55 -0700
Re: How to create an instance of a python class from C++ Bill <galaxyblue63@gmail.com> - 2014-03-05 05:42 -0800
Re: How to create an instance of a python class from C++ Grant Edwards <invalid@invalid.invalid> - 2014-03-05 16:08 +0000
Re: How to create an instance of a python class from C++ Alister <alister.ware@ntlworld.com> - 2014-03-05 17:00 +0000
Re: How to create an instance of a python class from C++ Grant Edwards <invalid@invalid.invalid> - 2014-03-05 17:14 +0000
Re: How to create an instance of a python class from C++ Gene Heskett <gheskett@wdtv.com> - 2014-03-05 17:21 -0500
Re: How to create an instance of a python class from C++ Barry Scott <barry@barrys-emacs.org> - 2014-03-11 21:37 +0000
Re: How to create an instance of a python class from C++ Stefan Behnel <stefan_ml@behnel.de> - 2014-03-12 18:10 +0100
csiph-web