[C++-sig] Mapping C++ typedefs to Python
Sylvain.Pion at sophia.inria.fr
Wed Nov 7 20:12:36 CET 2007
Stefan Seefeld a écrit :
> Nat Goodspeed wrote:
>> Sylvain Pion wrote:
>>> I use typedefs in C++, that is, several names for the same type
>>> (enums in my case).
>>> Is it possible to export this in Python?
>>> Is there the equivalent of typedefs in Python, and how
>>> can I specify this using Boost.Python?
>> If you have several C++ names for the same type, wouldn't it work to
>> export each of them as though they were distinct? Unless I'm missing
>> something, neither Python nor Boost.Python needs to know their sameness.
> That's technically correct, though I'm not sure what the purpose of this
> would be. Why duplicate code like this ? In Python type aliases are even
> easier than in C++, as types are assignable objects. So, why do it from
> within boost.python, and not inside python ?
> class Foo: pass
> Bar = Foo # 'Bar' is now the equivalent of C++'s typedef, aliasing 'Foo'
Thanks everybody for the suggestions and explanations.
I finally solved the problem within Python.
The reason I asked to do this within C++ using Boost.Python is that
this would have regrouped my code in the same place (after all, this
is a property of the C++ code which I want to describe).
BTW, this comes from me porting CGAL-Python to CGAL 3.3.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 4309 bytes
Desc: S/MIME Cryptographic Signature
More information about the Cplusplus-sig