
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)


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

    def __getattr__(self, attr):
        return None


if __name__ == '__main__':
    input_dict = json.load(sys.stdin)
    dw = DictWrapper(input_dict)
    json.dump(dw.eval_script(), sys.stdout)

Implement __getattr__ to handle KeyErrors
Implement __getattr__ to handle KeyErrors

  
  import json
  import sys
- import os # For os.path and the like
+ 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
+         return eval(self.script)  # With self as context
+ 
+     def __getattr__(self, attr):
+         return None
  
  
+ if __name__ == '__main__':
- d = json.load(sys.stdin)
+     input_dict = json.load(sys.stdin)
- dw = DictWrapper(d)
+     dw = DictWrapper(input_dict)
- json.dump(dw.eval_script(), sys.stdout)
+     json.dump(dw.eval_script(), sys.stdout)
  
Implement __getattr__ to handle KeyErrors
## Code Before:

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)

## Instruction:
Implement __getattr__ to handle KeyErrors
## Code After:

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

    def __getattr__(self, attr):
        return None


if __name__ == '__main__':
    input_dict = json.load(sys.stdin)
    dw = DictWrapper(input_dict)
    json.dump(dw.eval_script(), sys.stdout)
