Path: csiph.com!feeder.erje.net!2.eu.feeder.erje.net!newsfeed0.kamp.net!newsfeed.kamp.net!fu-berlin.de!uni-berlin.de!not-for-mail From: Antoon Pardon Newsgroups: comp.lang.python Subject: Re: Is '*args' useful in this example code? Date: Tue, 5 Jan 2016 12:51:52 +0100 Lines: 38 Message-ID: References: <6b0e236f-b240-486d-95e6-17bba9458cde@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de /Xhus86mFsVqWrP7cCjLnwvj6TU8URN2LWzjBzF3jKmw== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.012 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'args': 0.04; 'received:134': 0.05; "subject:' ": 0.07; 'subject:code': 0.07; '*args': 0.09; 'def': 0.13; 'b):': 0.16; 'received:ac.be': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'weird.': 0.16; 'code.': 0.23; 'thanks,': 0.24; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'example': 0.26; '**kwargs)': 0.29; '**kwargs):': 0.29; 'code:': 0.29; 'print': 0.30; 'code': 0.30; 'received:be': 0.30; 'wrap': 0.33; 'but': 0.36; 'to:addr:python- list': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'hi,': 0.38; 'to:addr:python.org': 0.40; 'your': 0.60; 'here': 0.66; 'link:': 0.69; 'func(*args,': 0.84; 'pardon': 0.84; 'schreef': 0.84; 'subject:this': 0.85 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAGAD2ti1aGuA9G/2dsb2JhbABehAxHASaIWLVWIoVtAoFnAQEBAQEBhUABAQQjVRELGgIFFgsCAgkDAgECAUUTCAKIKw6wKo5Ygi0BAQgCIYEBhVWEf4UjglCBSQWXCIVCiBGBXEqGdYViik6Dc2SEC4YBAQEB User-Agent: Mozilla/5.0 (X11; Linux i686; rv:38.0) Gecko/20100101 Icedove/38.5.0 In-Reply-To: <6b0e236f-b240-486d-95e6-17bba9458cde@googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:101268 Op 05-01-16 om 03:16 schreef Robert: > Hi, > > I find an example code on wrap at this link: > http://stackoverflow.com/questions/308999/what-does-functools-wraps-do > > Here is the code: > //////// > def logged(func): > def with_logging(*args, **kwargs): > print func.__name__ + " was called" > return func(*args, **kwargs) > return with_logging > /////// > > 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? > > > Thanks, You want the following to work def add(a, b): return a + b def double(n) return n + n logged_add = logged(add) logged_double = logged(double) s = logged_add(3, 5) d = logged_double(13) -- Antoon Pardon