My Function does not work with input IN[0]?

Hello,

Learning…

Why does my function not work when the imput comes from IN[0] ? how can i convert my Input not beeing a list or viceversa, how can i change my code that is dealing with a list-imput, i need a loop at some place? inside the function or outside?


def concat(*args, sep="."):
    return sep.join(args)
    
x = concat(IN[0])

OUT = x

it is working:

def concat(*args, sep="."):
    return sep.join(args)
    
x = concat("earth", "mars", "venus")

OUT = x

How can i deal with the issue , whether i don`t know if it is a list or a single value ?
2022-05-19_16h25_15

KR

Andreas

Hi,

This works for me, I’m not sure what the * notation did, (I’m not that good at Python)…

You’ll see ‘isinstance’ in lots of nodes to ensure things are always in a list…

Hope that helps,

Mark

2 Likes

@Mark.Ackerley
they call it KeyParameters … *

There is a difference between Positional Arguments and Keyword Arguments ( As in my tutorial)
Actually i can`t understand the topic

1 Like

Edit, you are right :slight_smile:

3 Likes

I guess it is failing because in Dynamo you are passing a List, which has a defined order?

My knowledge is now exhausted :smiley:

1 Like

this is correct, the message kind of contains the issue - *args expects multiple arguments - (variardic)

but you are not passing a variable number of strings, you are passing a single list.
try this:

3 Likes

From my understanding *args means that you have x number of arg inputs to your function. Each argument still requires a singleton in this case, but you can provide as many as you like. A list is still not a singleton. It’s similar to the scalable nodes in Dynamo that allow for +/- number of inputs. You can provide any number of inputs but the structure of the input is still dependent on the function.

1 Like

if necessary, you can unpack your list at argument,
example with 2 list

2 Likes