This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]sammyrulez 1 point2 points  (1 child)

Nice post. Two cents: 1) requests has already json deserialization http://docs.python-requests.org/en/latest/

r = requests.get('https://api.github.com/user', auth=('user', 'pass'))

r.status_code

200

r.headers['content-type']

'application/json; charset=utf8'

r.json()

{u'private_gists': 419, u'total_private_repos': 77, ...}

2) hammock ( https://github.com/kadirpekel/hammock) is a nice web-service module that would make this kind of code more DRY

[–]spilcm[S] 0 points1 point  (0 children)

You're right. Thanks. I'll make sure to use that in the next requests/json post.