Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Wrappers in python (http://www.velocityreviews.com/forums/t742684-wrappers-in-python.html)

sl33k_ 01-27-2011 12:10 PM

Wrappers in python
 
What are wrappers?

What entities do they wrap around?

Struggling to understand the concept.

Jean-Michel Pichavant 01-27-2011 12:57 PM

Re: Wrappers in python
 
sl33k_ wrote:
> What are wrappers?
>
> What entities do they wrap around?
>
> Struggling to understand the concept.
>

We would need a little bit of a context to answer that question, you
could be refering to differents things.

I'll give it a try on one common usage for wrapper:

A wrapper is a python module that interface between python and a 3rd
party library offering a non python interface.

Consider Google chart api.

This is the native URL API:
https://chart.googleapis.com/chart?cht=p3&chd=t:60,40&chs=250x100&chl=Hello|Wor ld


pygooglechart is the python wrapper for that api, allowing you to get
the same effect, using Python objects:

from pygooglechart import PieChart3D
# Create a chart object of 250x100 pixels
chart = PieChart3D(250, 100)
# Add some data
chart.add_data([20, 10])
# Assign the labels to the pie data
chart.set_pie_labels(['Hello', 'World'])
# Print the chart URL
print chart.get_url()

Python wrapper allows users to write only python code, even when calling
non python 3rd libraries.

Another example of wrapper is pgdb. It allows you to interface with a
postgreSQL database without knowing about the native interface, you can
commit and fetch data from the database by writing python code only. Nice !

JM

Raymond Hettinger 01-27-2011 10:15 PM

Re: Wrappers in python
 
On Jan 27, 4:10*am, sl33k_ <ahsanbag...@gmail.com> wrote:
> What are wrappers?
>
> *What entities do they wrap around?
>
> Struggling to understand the concept.


http://www.castle-cadenza.demon.co.uk/wrapper.htm

Raymond


All times are GMT. The time now is 12:00 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.