# ghPythonLib Branching Output Comprehension

**URL:** <https://discourse.mcneel.com/t/ghpythonlib-branching-output-comprehension/37179>\
**Category:** Serengeti (Rhino BETA)\
**Created:** [September 25, 2016, 10:18pm UTC](https://discourse.mcneel.com/t/ghpythonlib-branching-output-comprehension/37179 "2016-09-25T22:18:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![brobes05](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/brobes05/32/150947_2.png) [@brobes05](https://discourse.mcneel.com/u/brobes05)\
**Post date:** [September 25, 2016, 10:18pm UTC](https://discourse.mcneel.com/t/ghpythonlib-branching-output-comprehension/37179/1 "2016-09-25T22:18:21Z")

</div>

Hi, I am very pleased to hear about the implementation of the ‘ghpythonlib’ library into Serengeti’s ghPython.  
Nevertheless, I have some issues trying to understand how it works.

When I create a nested list within ghPython, I get the normal \> IronPython.Runtime.List; however, when I run the below code, the output is not updated as a a tree with branches

```
import rhinoscriptsyntax as rs
import Rhino.Geometry as rg
import ghpythonlib as gh

a = []

result = list(map(list, (pts0, pts1)))
gh.treehelpers.list_to_tree(result)
a.append(result)
print result

```

Incidentally, the old way works, but I’d like to get around this extra coding.

```
import rhinoscriptsyntax as rs
import clr
clr.AddReference("Grasshopper")
import Grasshopper as gh

#input list weaving into nested sublists
result = list(map(list, zip(pts0, pts1)))  

    
def pythonListTGhDataTree(someList):
    
    dataTree = gh.DataTree[object]()
    
    for i,l in enumerate(someList):
        for v in l:
            dataTree.Add(v,gh.Kernel.Data.GH_Path(i))
            
    return dataTree

a = pythonListTGhDataTree(result)

```

 ![](https://global.discourse-cdn.com/mcneel/uploads/default/original/3X/a/4/a422981f3a6b03219288a08f93831814fab14738.PNG)

[pythonTestingSerengeti.gh](https://global.discourse-cdn.com/mcneel/uploads/default/original/3X/b/e/bec1efa7733bc1030d49a4a80a4b909f0aa4bd8c.gh) (6.8 KB)

---

<div class="post-metadata">

**Author:** ![brobes05](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/brobes05/32/150947_2.png) [@brobes05](https://discourse.mcneel.com/u/brobes05)\
**Post date:** [September 26, 2016, 6:14am UTC](https://discourse.mcneel.com/t/ghpythonlib-branching-output-comprehension/37179/2 "2016-09-26T06:14:39Z")

</div>

Figured it out. This is such a great addition to the library!! 🌲

```
import rhinoscriptsyntax as rs
import ghpythonlib as gh

a = []
b = []

list_a = []
for i in range(10):
    pts = rs.AddPoint(i**2,0,0)
    list_a.append(pts)
    
list_b = []
for i in range(10):
    pts1 = rs.AddPoint(i**2,5,0)
    list_b.append(pts1)

b.extend([list_a, list_b])
a = gh.treehelpers.list_to_tree(b, True, [0])
```
