5.2.1. Tangler Constructors

In the previous example, we used the line
  @py = tangler('interscript/tests/output/mymodule.py')
to construct a tangler object. The general form of the tangler constructor is
  tangler(device,language, *args, **kwds)
The language is a programming language must be the interscript key for a particular tangler, which is named as the key plus the suffix '_tangler'. The tangler must be defined in a module language and prefixed with 'interscript.tanglers.'.

If the language is not given, it defaults to 'deduce', which tells the function to guess the right tangler by examining the filename extension. Therefore the example above is equivalent to

  @py = tangler('interscript/tests/output/mymodule.py', 'python')
because interscript knows that the extension 'py' is for a python code target. If deduction cannot pick a specialised tangler, the built-in data tangler is used.

The device argument can be an object supporting sink protocol, in which case that sink object is used directly. The device argument can be an object supporting filename protocol, in which case a named_file_sink object for that file is automatically created as the tangler sink. Note that strings support filename protocol, which is why the example works.

The balance of the arguments are passed to the tangler as options.