[C++-sig] Pyste and STL types

David Abrahams dave at boost-consulting.com
Tue Mar 18 16:06:32 CET 2003


Patrick Hartling <patrick at vrac.iastate.edu> writes:

> Thanks very much, Nicodemus, things are much improved now.
>
> Based on further usage, I have a question: are unions supported?  

Almost certainly not.

> I am not a Python guru, but I don't think that there is a union
> concept in Python.  

Sure there is:

     x = 1
     x = 'hello'
     x = 3.14
     type(x)
     
;-)

In other words, in Python everything is a union.

> In that case, it would make sense if Pyste ran into a problem with a
> class containing a public data member that is a union type.  I would
> grant that the C++ class I have in mind should probably encapsulate
> its data better, but in the meantime, should exclude() work to keep
> the union data member out of the mix?  

Probably a good idea.  Eventually, this is the sort of problem that
can be handled by something like Pyste but not easily by Boost.Python
alone.  In order to do the wrapping, you'd need to provide Pyste with
a function that it could use to determine which member of the union
was "active".

Come to think of it, I guess you could use Boost.Python properties
with appropriate C++ accessor functions to expose a union data member.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com





More information about the Cplusplus-sig mailing list