code: def load_ipython_extension(ipython):
      
      # add Coconut built-ins
      from coconut import __coconut__
      newvars = {}
      for var, val in vars(__coconut__).items():
          if not var.startswith("__"):
              newvars[var] = val
      ipython.push(newvars)
  
      # import here to avoid circular dependencies
      from coconut.convenience import cmd, parse, CoconutException
      from coconut.terminal import logger
  
      # add magic function
      def magic(line, cell=None):
          """Provides %coconut and %%coconut magics."""
          try:
              if cell is None:
                  code = line
              else:
                  # first line in block is cmd, rest is code
                  line = line.strip()
                  if line:
                      cmd(line, interact=False)
                  code = cell
              compiled = parse(code)
          except CoconutException:
              logger.display_exc()
          else:
              ipython.run_cell(compiled, shell_futures=False)
      ipython.register_magic_function(magic, "line_cell", "coconut")
docs: Loads Coconut as an IPython extension.