Skip to content

Instantly share code, notes, and snippets.

@tomislater
Created October 6, 2013 16:40
Show Gist options
  • Select an option

  • Save tomislater/6856182 to your computer and use it in GitHub Desktop.

Select an option

Save tomislater/6856182 to your computer and use it in GitHub Desktop.
>>> from __future__ import division
>>> from collections import namedtuple
>>> json_data = {
>>> "id": 63082999,
>>> "title": "Le retour",
>>> "upload_date": "2013-04-01 08:46:22",
>>> "user_id": 13095550,
>>> "user_name": "Natalia Chernysheva",
>>> "likes": 930,
>>> "plays": 50586,
>>> "comments": 45,
>>> "duration": 87,
>>> "width": 1280,
>>> "height": 720,
>>> "tags": ""
>>> }
>>> VimeoStats = namedtuple(
>>> "VimeoStats",
>>> "id, title, upload_date, user_id, user_name, likes, plays, comments, duration, width, height, tags"
>>> )
>>> v = VimeoStats(**json_data)
>>> print v.user_name
Natalia Chernysheva
>>> print v.plays / v.likes
54.3935483871
>>> print v.width / v.height
1.77777777778
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment