0

I'm currently try to pass the items of a list create an instance of a class.

My code looks like this

args = ["1", "John", "Doe"]

class Token:
    def __init__ = (self, id, name, last_name)
        self.id = id
        self.name = name
        self.last_name = last_name

instance1 = Token(args)

I get the error

TypeError: Token.__init__() missing 3 required positional arguments:

I tried changing the type, the data I received comes from a previous for loop that filters the data I need.

Expecting

To create an instance with the values of the list and pass them as args.

Note

The topple is currently in order

0

1 Answer 1

1

Use the iterable unpacking operator:

Token(*args)
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.