“TypeError: (Integer) is not JSON serializable” when serializing JSON in Python?

I am trying to send a simple dictionary to a json file from python, but I keep getting the “TypeError: 1425 is not JSON serializable” message. import json alerts = {‘upper’:[1425],’lower’:[576],’level’:[2],’datetime’:[‘2012-08-08 15:30’]} afile = open(‘test.json’,’w’) afile.write(json.dumps(alerts,encoding=’UTF-8′)) afile.close() If I add the default argument, then it writes, but the integer values are written to the json … Read more

Uncaught TypeError: (intermediate value)(…) is not a function

Everything works fine when I wrote the js logic in a closure as a single js file, as: (function(win){ //main logic here win.expose1 = …. win.expose2 = …. })(window) but when I try to insert a logging alternative function before that closure in the same js file, window.Glog = function(msg){ console.log(msg) } // this was … Read more

TypeError: not all arguments converted during string formatting python

The program is supposed to take in two names, and if they are the same length it should check if they are the same word. If it’s the same word it will print “The names are the same”. If they are the same length but with different letters it will print “The names are different … Read more

super() raises “TypeError: must be type, not classobj” for new-style class

The following use of super() raises a TypeError: why? >>> from HTMLParser import HTMLParser >>> class TextParser(HTMLParser): … def __init__(self): … super(TextParser, self).__init__() … self.all_data = [] … >>> TextParser() (…) TypeError: must be type, not classobj There is a similar question on StackOverflow: Python super() raises TypeError, where the error is explained by the … Read more