Attaching C++ libraries to Python app.

Stefan Sonnenberg-Carstens stefan.sonnenberg at pythonmeister.com
Thu Jan 6 01:08:14 EST 2011


Am 05.01.2011 23:44, schrieb Rohit Coder:
> I am just asking. In future I may need to import any C++ library, not 
> a Crypto, but some other. Is it possible?
Yes.
There are at least five possible ways:

- Handcode the interface and glue code (http://docs.python.org/extending)
- use SWIG to autogenerate (mostly) the interface (http://www.swig.org)
- using BOOST's python interface 
(http://www.boost.org/doc/libs/1_45_0/libs/python/doc/index.html)
- using ctypes module for runtime interaction (like and use it a _lot_, 
very cool for rapid prototyping :-) 
http://docs.python.org/library/ctypes.html)
- cython (different approach, implements a python subset, http://cython.org)

I used SWIG and ctypes in the past, as it seems (for me) the easiest way.
>
> > Date: Wed, 5 Jan 2011 22:44:15 +0100
> > Subject: Re: Attaching C++ libraries to Python app.
> > From: stefan.sonnenberg at pythonmeister.com
> > To: passionate_programmer at hotmail.com
> > CC: python-list at python.org
> >
> > You don't need to reinvent the wheel:
> >
> > http://www.dlitz.net/software/pycrypto/
> >
> > Am Mi, 5.01.2011, 22:21 schrieb Rohit Coder:
> > >
> > > Is it possible to use C++ libraries within a Python application? I am
> > > planning to write an encryption program and want to use GnuPG C++
> > > 
> libraries.elementFontfont-familyfont-sizefont-stylefont-variantfont-weightletter-spacingline-heighttext-decorationtext-aligntext-indenttext-transformwhite-spaceword-spacingcolorBackgroundbg-attachmentbg-colorbg-imagebg-positionbg-repeatBoxwidthheightborder-topborder-rightborder-bottomborder-leftmarginpaddingmax-heightmin-heightmax-widthmin-widthoutline-coloroutline-styleoutline-widthPositioningpositiontopbottomrightleftfloatdisplayclearz-indexListlist-style-imagelist-style-typelist-style-positionTablevertical-alignborder-collapseborder-spacingcaption-sideempty-cellstable-layoutEffectstext-shadow-webkit-box-shadowborder-radiusOtheroverflowcursorvisibility
> > > ...................................................Rohit. --
> > > http://mail.python.org/mailman/listinfo/python-list
> > >
> >
> >
> > --
> > MfG,
> >
> > Stefan Sonnenberg-Carstens
> >
> > IT Architect
>
>
>     element
>
> Font
> font-family 	
> font-size 	
> font-style 	
> font-variant 	
> font-weight 	
> letter-spacing 	
> line-height 	
> text-decoration 	
> text-align 	
> text-indent 	
> text-transform 	
> white-space 	
> word-spacing 	
> color 	
> Background
> bg-attachment 	
> bg-color 	
> bg-image 	
> bg-position 	
> bg-repeat 	
> Box
> width 	
> height 	
> border-top 	
> border-right 	
> border-bottom 	
> border-left 	
> margin 	
> padding 	
> max-height 	
> min-height 	
> max-width 	
> min-width 	
> outline-color 	
> outline-style 	
> outline-width 	
> Positioning
> position 	
> top 	
> bottom 	
> right 	
> left 	
> float 	
> display 	
> clear 	
> z-index 	
> List
> list-style-image 	
> list-style-type 	
> list-style-position 	
> Table
> vertical-align 	
> border-collapse 	
> border-spacing 	
> caption-side 	
> empty-cells 	
> table-layout 	
> Effects
> text-shadow 	
> -webkit-box-shadow 	
> border-radius 	
> Other
> overflow 	
> cursor 	
> visibility 	
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110106/0ad9b6d3/attachment-0001.html>


More information about the Python-list mailing list