You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would also fail for any other number of parameters too.
193
+
194
+
Fortunately we can write decorators that don't care about the number of parameters a function may take by using the `*args` and `**kwargs` syntax.
195
+
Here's an update `@double` decorator:
196
+
```py
197
+
defdouble(f):
198
+
defwrapper(*args, **kwargs):
199
+
func_result = f(*args, **kwargs)
200
+
doubled = func_result *2
201
+
return doubled
202
+
return wrapper
203
+
```
204
+
Now we should be to use this decorator on functions which accept zero, one, two or even one million (though we wouldn't recommend that many!) parameters:
0 commit comments