Wrappers in python

Discussion in 'Python' started by sl33k_, Jan 27, 2011.

  1. sl33k_

    sl33k_ Guest

    What are wrappers?

    What entities do they wrap around?

    Struggling to understand the concept.
     
    sl33k_, Jan 27, 2011
    #1
    1. Advertising

  2. 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|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
     
    Jean-Michel Pichavant, Jan 27, 2011
    #2
    1. Advertising

  3. Raymond Hettinger, Jan 27, 2011
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paul Rudin

    python com wrappers

    Paul Rudin, Dec 9, 2003, in forum: Python
    Replies:
    3
    Views:
    397
    R.Marquez
    Dec 10, 2003
  2. Etienne Posthumus

    Anyone else using Python OpenSSL Wrappers?

    Etienne Posthumus, Jan 12, 2004, in forum: Python
    Replies:
    0
    Views:
    316
    Etienne Posthumus
    Jan 12, 2004
  3. Replies:
    0
    Views:
    264
  4. DreiJane
    Replies:
    0
    Views:
    267
    DreiJane
    Nov 23, 2009
  5. DreiJane
    Replies:
    0
    Views:
    283
    DreiJane
    Nov 23, 2009
Loading...

Share This Page