Working with JSON output from AWSCLI

The program looks short but the way Python handles JSON is not very elegant. JSON is supposed to be a serialized object, so it should be processed as an object. But here, it’s processed as an array. [python] #!/usr/bin/python import json import sys print "Usage: cat JSON | BasicParse.py | column -t" jsonInput = sys.stdin awsObject = json.load(jsonInput) instances = awsObject[‘Reservations’] for instance in instances: print instance[‘Instances’][0][‘Tags’][0][‘Value’], instance[‘Instances’][0][‘InstanceId’], instance[‘Instances’][0][‘PublicDnsName’] [/python]…

Read More

Hello python

I’m a Java guy and I just can’t convince myself to learn a new language – because there isn’t a better one. Let’s look at python for a second, there is visually no structure. Why is having {} blocks a problem? [python] #!/usr/bin/python3 # Imports import random s1 = "Let’s predict the next mark six!" print(s1) genEntries = 4 sysRandom = random.SystemRandom() while genEntries > 0: genNumbers = 17 selection…

Read More