On Monday, January 4, 2016 at 9:26:47 PM UTC-5, Ben Finney wrote: > Robert <rxjw...@gmail.com> writes: > > > I understand now, but I feel the args usage is weird. I don't see any way > > to use *args and **kwargs in above code. What is your opinion on it? > > Can you show example code that you would expect, and specifically what about > the actual code doesn't match what you expect? > > -- > \ "Of course, everybody says they're for peace. Hitler was for | > `\ peace. Everybody is for peace. The question is: what kind of | > _o__) peace?" --Noam Chomsky, 1984-05-14 | > Ben Finney
Excuse me for the incomplete info previously. If I call it with a = f(3) the result is 12. It is correct as below message. That is no use of *args and **kwargs. If I put more parameters in f, it will give errors as below. /////////// %run "C:/Users/pyprj/ipython0/decor0.py" f was called --------------------------------------------------------------------------- TypeError Traceback (most recent call last) C:\Users\pyprj\ipython0\decor0.py in <module>() 11 return x + x * x 12 ---> 13 a = f(3, 4) 14 C:\Users\pyprj\ipython0\decor0.py in with_logging(*args, **kwargs) 3 def with_logging(*args, **kwargs): 4 print func.__name__ + " was called" ----> 5 return func(*args, **kwargs) 6 return with_logging 7 TypeError: f() takes exactly 1 argument (2 given) %run "C:/Users/rj/pyprj/ipython0/decor0.py" f was called a Out[13]: 12 /////////// I don't see *args and **kwargs can be used by other way yet. Do you think this internal function definition (with *args) is useful? Thanks, -- https://mail.python.org/mailman/listinfo/python-list