Feeding an Ilist?

I’m trying to find out if it’s possible to feed an Ilist (it seems to have a class in System.Collection and also in System.Collection.Generic)
under CPython

is this already really an IList my starting point or not?

import sys
import clr
import System
from System.Collections.Generic import IList
from System import String

OUT = li

thanks in advance

Yes - it’s a C# IList.

Try adding a few strings to the list to see the change in result. Typically the Dynamo engine converts these (and most enumerable collections) to lists automatically.

1 Like

hi, thank you for answering, but by doing this I lose the status of Ilist (I don’t really know, I admit that it’s very nebulous for me, maybe I should see that later in my progression)

edit: as I use the same variable that comes after it is normal that he qualifies it as List
with Add,Append, I only have errors
Must be doing it wrong given the methods (on the .Net)

in reverse order i have this

last edit
and if I do a getitem I get a block (which goes I don’t know where)

I tried to put as much information as possible.

In python, an ICollection is just a List with a specified type.

The problem with most of your attempts come from redefining the collection by setting it equal to a new list of values. You either need to supply the list on creation (like you do on your third example) or Add the values to the existing collection.


I had seen a solution by M. Poupin yesterday in IronPython

and I was trying to adapt it in Cpython already yesterday without success, I try with something less complicated (but which I fear is still too complex for my few Skills)
thank you for taking the time to answer, i will re-read it with a clear head tomorrow.
Have a good evening