Thanks for starting this resource, looks really useful :)
|
# Custom method to convert single items to a list to iterate over, also unwraps the items. |
|
def toList(x): # the name of the function |
|
if isinstance(x,list): return UnwrapElement(x) # if the input element is a single thing, return it as a list. |
|
else : return [UnwrapElement(x)] # if the input thing was a list all along, just return that |
I was wondering why you used UnwrapElement is that always necessary?
or do you include it just in case its necessary?
sometimes I use this single line that I picked up from looking at packages
if not isinstance(inputs, list): inputs = [inputs]
which is pretty similar but skips over doing anything that is already a list so there wouldn't be the opportunity to UnwrapElement for objects that are already in a list
Thanks for starting this resource, looks really useful :)
dynamoPython/helpers/helpersConvertInputToList.py
Lines 22 to 25 in 05bbfb9
I was wondering why you used
UnwrapElementis that always necessary?or do you include it just in case its necessary?
sometimes I use this single line that I picked up from looking at packages
if not isinstance(inputs, list): inputs = [inputs]which is pretty similar but skips over doing anything that is already a list so there wouldn't be the opportunity to
UnwrapElementfor objects that are already in a list