# Python API documentation?

**URL:** <https://discourse.slicer.org/t/python-api-documentation/12298>\
**Category:** Development\
**Tags:** python, documentation, api\
**Created:** [June 30, 2020, 1:24pm UTC](https://discourse.slicer.org/t/python-api-documentation/12298 "2020-06-30T13:24:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![joachim](https://avatars.discourse-cdn.com/v4/letter/j/a87d85/32.png) [@joachim](https://discourse.slicer.org/u/joachim)\
**Post date:** [June 30, 2020, 1:24pm UTC](https://discourse.slicer.org/t/python-api-documentation/12298/1 "2020-06-30T13:24:18Z")

</div>

Is there an API documentation for the Python interface of Slicer? I haven’t found it.

What I’ve found is the [C++ documentation](http://apidocs.slicer.org/master/index.html), and I use this when I try to do Python. I guess the Python interface is generated from C++ in some way. I don’t need well-commented documentation, but I’m looking for all types and functions in Slicer’s Python interface, instead of using `Tab` in the Python Interactor. [The documentation for Qt’s Python API](https://doc.qt.io/qtforpython/PySide2/QtWidgets/QLabel.html) is a nice example of how Python documentation can be done.

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [June 30, 2020, 3:04pm UTC](https://discourse.slicer.org/t/python-api-documentation/12298/2 "2020-06-30T15:04:53Z")

</div>

Good point - we discussed this [at the developer hangout](https://discourse.slicer.org/t/2020-06-30-hangout/12286) and there isn’t a great universal solution given how many libraries slicer builds on an integrates. [Here’s a very old page](https://www.na-mic.org/wiki/AHM2012-Slicer-Python) that lists and links back to the various pieces.

We also noticed that while Qt’s Python documentation is good, it’s not perfect either. For example this [python documentation](https://doc.qt.io/qtforpython/PySide2/QtWidgets/QLabel.html#PySide2.QtWidgets.PySide2.QtWidgets.QLabel.linkActivated) just lists the method type, while the [corresponding C++ documentation includes useful text](https://doc.qt.io/qt-5/qlabel.html#linkActivated).

It would be great if someone wants to build a better doc infrastructure, but for now I suggest looking at the source code. And of course you can use `help` in the python interactor.

Hope that helps

---

<div class="post-metadata">

**Author:** ![joachim](https://avatars.discourse-cdn.com/v4/letter/j/a87d85/32.png) [@joachim](https://discourse.slicer.org/u/joachim)\
**Post date:** [June 30, 2020, 3:42pm UTC](https://discourse.slicer.org/t/python-api-documentation/12298/3 "2020-06-30T15:42:35Z")

</div>

At this point I would be very satisfied by just listing the method and types like in the Qt’s Python API documentation. It’s so much easier to program when you can browse the API. I didn’t know about `help()` - thank you, I’m still learning Python.

#### A short question

I want to set “Modify other segments” to “Allow overlap” in my _.slicerrc_ file:

```auto
ne = getNode( 'SegmentEditor' ) # singleton, type: vtkSlicerSegmentationsModuleMRMLPython.vtkMRMLSegmentEditorNode, according to Python Interactor
ne.SetOverwriteMode( 2 ) # magic number, see https://github.com/Slicer/Slicer/blob/e33439f950cca5a63976d249851eac6f52bc2530/Modules/Loadable/Segmentations/MRML/vtkMRMLSegmentEditorNode.h#L77-L87

```

How do I replace the magic number with a Python equivalent to [C++'s `vtkMRMLSegmentEditorNode::OverwriteNone`](https://github.com/Slicer/Slicer/blob/e33439f950cca5a63976d249851eac6f52bc2530/Modules/Loadable/Segmentations/MRML/vtkMRMLSegmentEditorNode.h#L77-L87)? It looks like I can use ` ne.OverwriteNone`, but that is not a static value. And `vtkMRMLSegmentEditorNode.OverwriteNone` is not defined, Python Interactor says.

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [June 30, 2020, 4:15pm UTC](https://discourse.slicer.org/t/python-api-documentation/12298/4 "2020-06-30T16:15:17Z")

</div>

> [@joachim](#):
>
> And `vtkMRMLSegmentEditorNode.OverwriteNone` is not defined, Python Interactor says.

`slicer.vtkMRMLSegmentEditorNode.OverwriteNone` will work
