Wrappers in python

S

sl33k_

What are wrappers?

What entities do they wrap around?

Struggling to understand the concept.
 
J

Jean-Michel Pichavant

sl33k_ said:
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|World


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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top