#!/usr/bin/env python

import json
import sys
import os # For os.path and the like

class DictWrapper(object):
    def __init__(self, d):
        self.__dict__ = d
    def eval_script(self):
        return eval(self.script) # With self as context


d = json.load(sys.stdin)
dw = DictWrapper(d)
json.dump(dw.eval_script(), sys.stdout)

@@ -49,16 +49,18 @@
 port os 
+  
 # For os
@@ -79,16 +79,17 @@
 e like%0A%0A
+%0A
 class Di
@@ -160,16 +160,17 @@
 t__ = d%0A
+%0A
     def 
@@ -220,16 +220,17 @@
 .script)
+ 
  # With 
@@ -246,18 +246,112 @@
 ontext%0A%0A
-%0Ad
+    def __getattr__(self, attr):%0A        return None%0A%0A%0Aif __name__ == '__main__':%0A    input_dict
  = json.
@@ -366,16 +366,20 @@
 .stdin)%0A
+    
 dw = Dic
@@ -391,11 +391,24 @@
 per(
-d)%0A
+input_dict)%0A    
 json

Implement __getattr__ to handle KeyErrors