param.script_repr(val, imports=None, prefix='\n    ', settings=[], qualify=True, unknown_value=None, separator='\n', show_imports=True)[source]#

Variant of pprint() designed for generating a (nearly) runnable script.

The output of script_repr(parameterized_obj) is meant to be a string suitable for running using python Not every object is guaranteed to have a runnable script_repr representation, but it is meant to be a good starting point for generating a Python script that (after minor edits) can be evaluated to get a newly initialized object similar to the one provided.

The new object will only have the same parameter state, not the same internal (attribute) state; the script_repr captures only the state of the Parameters of that object and not any other attributes it may have.

If show_imports is True (default), includes import statements for each of the modules required for the objects being instantiated. This list may not be complete, as it typically includes only the imports needed for the Parameterized object itself, not for values that may have been supplied to Parameters.

Apart from show_imports, accepts the same arguments as pprint(), so see pprint() for explanations of the arguments accepted. The default values of each of these arguments differ from pprint() in ways that are more suitable for saving as a separate script than for e.g. pretty-printing at the Python prompt.