python - How can I use a decorator to modify the type of *args? -


i use @decorator allow me able access ' - '.join(args) args, depicted below. possible, using metaclass perhaps?

def a(*args):     print(args) a(1, 2, 3) # (1, 2, 3)  @magic def b(*args):     print(args) b(1, 2, 3) # 1 - 2 - 3 

you can close:

def magic(func):     def wrapper(*args):         return func(' - '.join(map(str, args)))     return wrapper 

but prints out ('1 - 2 - 3',) because body of b sees args tuple due *args, , doubt decorator can around that. expect happen if body print(args[1])?