I tried using the list method, List.copy () and list.clear () and it wasn’t working. Could anybody help me?
Can you tell us what the goal of the script is? Here is a working version where you don’t need to copy the list or clear it, as it will reset to an empty list at the start of each iteration.
# The inputs to this node will be stored as a list in the IN variables.
listas = IN[0]
l = []
output = []
for lista in listas:
l1 = []
for n in lista:
if n is None:
n = 0
l1.append(n)
l1.sort()
l.append(l1)
for lista in l:
output.append(lista[-1])
OUT = output
1 Like
Python 2.7 lists do not have a copy method. You can either create a copy using object slice syntax or by importing the copy module.
import sys
sys.path.append(r'C:\Program Files (x86)\IronPython 2.7\Lib')
import copy
list_in = IN[0]
list_copy = copy.copy(list_in)
list_slice = list_in[:]
OUT = list_copy, list_slice
2 Likes
Thanks man, it worked!!
Thanks man, could i import python library?
You can import most standard python modules contained in IronPython’s Lib folder after you have added it to your PATH:
import sys
sys.path.append(r'C:\Program Files (x86)\IronPython 2.7\Lib')
Then you can import other standard modules like math
, csv
, json
, StringIO
, etc. Modules written in C (numpy
, scipy
) cannot be imported.
1 Like