More Related Content Similar to Zpugdccherry 101105081729-phpapp01 Similar to Zpugdccherry 101105081729-phpapp01 (20) More from Jeffrey Clark (19) Zpugdccherry 101105081729-phpapp011. Producing Python Wrappers for C++ Libraries Using SWIG Joshua L. Cherry, Ph.D. National Center for Biotechnology Information National Library of Medicine National Institutes of Health [email_address] 10. Shared Library C++ Code Python Code Compile, link SWIG Interface Files (point at C++ headers) SWIG 13. %module example %include stl.i %template(vector_int) std::vector<int>; int prod(const std::vector<int>& vec); >>> import example >>> vec = example.vector_int() >>> vec.append(42) # append mapped to vector::push_back >>> vec.append(98) >>> vec.append(47) >>> len(vec) # __len__ mapped to vector::size 3 >>> example.prod(vec) # normal class usage 193452 >>> >>> example.prod([42, 98, 47]) # works because of "in" typemap 193452 >>> vec2 = example.vector_int([42, 98, 47]) STL Support Example 21. Josh Cherry [email_address] SWIG www.swig.org NCBI C++ Toolkit Wrappers www.ncbi.nlm.nih.gov/cvsweb/index.cgi/internal/c++/src/wrappers/