Skip to content
Advertisement

Args do not unpack

I’m learning flask and i want to unpack args in inner function. That’s my code:

JavaScript

I’m getting an arror “tuple index out of range” even if I add next asterix in

JavaScript

Can I unpack it anywhere else?

Advertisement

Answer

If you print args and kwargs, you will find that user is passed in kwargs (by calling func(user=xxx)). The problem is that you usually cannot assume how the arguments are passed, so you should write return f"<b>{func(*args, **kwargs)}</b>" instead.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement