Python Tutorial

Wednesday, June 4, 2014

Python multi threading vs multi processing



A very good article on python multi threading vs multi processing

Python Requests: HTTP for Humans


Python requests module provides very interactive way to access web content via proper HTTP protocol.

Installation:
Here is the installation manual. You can also install using pip :
pip install requests

import requests

r = requests.get('https://api.github.com/user', auth=('user', 'pass'))
print r.status_code
print r.headers['content-type']
print r.encoding
print r.text
print r.json()

Output:
200
'application/json; charset=utf8'
'utf-8'
u'{"type":"User"...'
{u'private_gists': 419, u'total_private_repos': 77, ...}


Python webbrowser


Python webrowser provides high-level interface to displaying Web-based documents.
import webbrowser

url ='https://docs.python.org'
webbrowser.open(url, new=0, autoraise=True)


Output:

This code will open url to existing web browser and raised the window.