Skip to main content

Posts

Showing posts from March, 2013

Request module: non-callable Dict Object

So, you are using the amazing requests module of Python! So checked their sample code in the website: http://docs.python-requests.org/en/latest/ and the URL you are calling returns json content. So you followed their example and came up with a code like this: import requests url = '' # put your url here r = requests.get(url) json_content = r.json() print json_content When you run the program, you get the following error: json_content = r.json() TypeError: 'dict' object is not callable Now you are wondering what is this! An example from the home page doesn't work. So you searched Google and came here. Now you solve the problem using json_content = r.json instead of json_content = r.json() So this code will work (Python 2.7): import requests url = '' # put your url here r = requests.get(url) json_content = r.json print json_content If you are wondering why you got the error in the first code, let me give you a hint. Add the followi

Technology: The Dizziness of unseen Depth

You just went to the Google home page. Simple, isn't it? What just actually happened? Well, when you know a bit of about how browsers work, it's not quite that simple. You've just put into play HTTP, HTML, CSS, ECMAscript, and more. Those are actually such incredibly complex technologies that they'll make any engineer dizzy if they think about them too much, and such that no single company can deal with that entire complexity. Let's simplify. You just connected your computer to  www.google.com . Simple, isn't it? What just actually happened? Well, when you know a bit about how networks work, it's not quite that simple. You've just put into play DNS, TCP, UDP, IP, Wifi, Ethernet, DOCSIS, OC, SONET, and more. Those are actually such incredibly complex technologies that they'll make any engineer dizzy if they think about them too much, and such that no single company can deal with that entire complexity. Let's simplify. You just typed  www.google.c