# export_python

Python reference for `nagasim.build.export_python`.

`nagasim.build.export_python`

```python
export_python(layout: str | PathLike[str] | dict[str, Any])
```

Return builder code for a model.

Running the code gives ``m``, whose ``to_dict()`` is the model in ``naga fmt``
form. Every value is written as a Python literal (``repr``), and a
distribution as its constructor when its name and keys are the registry's, so
no text of the model ever becomes code.

Parameters
----------
layout : str or dict
    A path or a layout dict.

Returns
-------
str
    Python source.

See Also
--------
nagasim.build.Model : What the code builds.

Examples
--------
>>> from nagasim import build as nb
>>> m = nb.Model(time_limit=10)
>>> _ = m.create(distribution=nb.Exponential(rate=1.0)) >> m.dispose()
>>> code = nb.export_python(m.to_dict())
>>> code.splitlines()[0]
'from nagasim import build as nb'
>>> namespace = {}
>>> exec(code, namespace)
>>> namespace["m"].to_dict() == m.to_dict()
True
