Convert Linux's curl program to a python code
Question: I need to convert the following curl program to equivalent python program and
also want to know how to store the response of this request which is a csv
file in python.

curl --data-binary @obama.txt
"<http://www.sentiment140.com/api/bulkClassify?query=obama>"

This is a program used for calculating sentiment score for each tweet in the
text file obama.txt.

ex: obama.txt may contain: \n obama is awesome \n I do not know who is obama
\n obama is eating a potato

(\n = new line)

the --data-binary flag tells curl to preserve the new line character in the
sent data set, and the @obama.txt tells curls which filename to read the data
from

The response will be a CSV with two fields: -polarity. The polarity values
are: 0: negative 2: neutral 4: positive -the text

How can I possibly implement the same functionality in python. I have very
less experience in using python so if someone can give the exact code then it
would be really appreciated.


Answer: Use python [requests](http://docs.python-requests.org/en/latest/) library

    
    
    >>> import requests
    >>> with open('obama.txt','r') as f:
    ...     text = f.read()
    ... 
    >>> r=requests.post('http://www.sentiment140.com/api/bulkClassify?query=obama',data=text)
    
    >>> print r.text
    "4","obama is awesome"
    "2","I do not know who is obama"
    "2","obama is eating a potato"
    

