input: Write a function to create an Environment object capable of executing and analyzing Python code. The Environment includes a set of predefined global variables and functions, and allows for adding additional global variables. It can execute Python code, analyze variable usage and imports, and includes a stdout object to capture and display output from executed code.
  assert create_environment('/path/to/directory').globals['__builtins__'] == __builtins__
  assert create_environment('/path/to/directory').globals['print'] == jsonify_print
  assert create_environment('/path/to/directory').globals['FILES'].path == '/path/to/directory'
  assert isinstance(create_environment('/path/to/directory').init_commands(), types.GeneratorType)
  assert create_environment('/path/to/directory').execute('test.py', 'print("Hello, World!")') is None
output: def create_environment(directory):
      class FILES:
          def __init__(self, path):
              self.path = path
  
      def jsonify_print(*args, **kwargs):
          import json
          print(json.dumps(args))
  
      class Environment:
          def __init__(self, directory):
              self.globals = {
                  '__builtins__': __builtins__,
                  'print': jsonify_print,
                  'FILES': FILES(directory)
              }
  
          def init_commands(self):
              yield "Initial command"
  
          def execute(self, filename, code):
              exec(code, self.globals)
  
      return Environment(directory)