Skip to content
Advertisement

Tag: python-decorators

Args do not unpack

I’m learning flask and i want to unpack args in inner function. That’s my code: I’m getting an arror “tuple index out of range” even if I add next asterix in Can I unpack it anywhere else? 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

Function wrapper for multiple code lines in Python

I would like to wrap some code around a function (e.g. print timing information) and reuse this function for multiple code blocks: Is it possible to wrap multiple lines of code into a wrapper function, without defining functions for each code blocks? One way would be to define a function and use a decorator but I would like to avoid

Advertisement