Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Ian Kelly Newsgroups: comp.lang.python Subject: Re: Meta decorator with parameters, defined in explicit functions Date: Sat, 2 Jul 2016 22:48:11 -0600 Lines: 17 Message-ID: References: <85mvm5vrbw.fsf@benfinney.id.au> <21916e7b-9e19-4cef-94e0-bac331540ca2@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de 7wVITd1kMpRx7MXyB18BcQUT/pOC7dX10TaGmSvAwp+Q== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'that?': 0.05; '*args,': 0.07; 'func': 0.09; 'def': 0.13; 'applies': 0.15; '"""returns': 0.16; '2016': 0.16; 'posted:': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'skip:@ 20': 0.16; 'subject:parameters': 0.16; 'wrote:': 0.16; '>>>': 0.20; 'decorator': 0.22; 'lawrence': 0.22; 'am,': 0.23; 'sat,': 0.23; 'header:In-Reply-To:1': 0.24; 'message-id:@mail.gmail.com': 0.27; '**kwargs):': 0.29; 'received:google.com': 0.35; 'should': 0.36; 'instead': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'doing': 0.38; 'to:addr:python.org': 0.40; 'where': 0.40; 'subject:with': 0.40; 'skip:u 10': 0.61; 'saturday,': 0.63; 'jul': 0.72; 'to:name:python': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-transfer-encoding; bh=qaympLUsSbTdmNPJfvYtt2KbFYHZu/zkYUp9/xN7s2c=; b=F0oQuKmPiuEBzteaZLDIR0JZWcSsMDio92qaLpwsNHyzC8eGnN5f3fby44LhATjiHz 1XmGbJznUEpDPhrTuFnamAA+BVS8hpkQkCSzyoi716yoqNEypc5po7VQX/ZDxOT4QzMG zc+cGM37f5lEYMZvZByqrPiX1QMi6u67PqmpBrl88EQ34vsWm0Q0vPVjMvxh6DjJxkh8 x2l//vGIUM1vM5NVOkKYhmmM3J6zQqTOEWiFJl+Cd7bCF6yS3RhYiGFpLDyDeFa4rHqM DtBVn6TqPWNQCA0YIBv3igohAceuF6IEE+IIksofRSrWsShRhDXOgp5VgQwKd/tKWVSC NppQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-transfer-encoding; bh=qaympLUsSbTdmNPJfvYtt2KbFYHZu/zkYUp9/xN7s2c=; b=Z1fIjpyA//XvvtIJbsgDB/vKm+LLliU9tMk8WNMiTJhJ7OPk8IZCBHIPmeGNuAZgrp c0dF9CuCQqjkZZSo5AklYfj/YhUuvJAObOpsFddLEB0pRdz4BDgvB6z367VNVeSHyOtC MPb6wypzpK8i3WyyyqORDPVXtqWuSMcW/gmPqzZk88OFcmWJKpd3cEOJ1VAO8MMVixZA EEm3dnFz5TMhy2GLufZ6zlPnDJTd+3DWdPQgf5TyWcRDUbo4HX/gzc9DjXZEGZDm9oBg ODpuVeG4cSdzqrbW0w+fEuyIrh/iN1wCV74XkFB5Bk3wVRmuFLsVLTpV/f3P6400NSrA L0aw== X-Gm-Message-State: ALyK8tIN+rNbWz9GLZ0tcnF5mkHxpKDyplftUnN8Qqb4pPpDwPRqehieDO7ADwSBqsKS/TcQbLF3UYyuwIt5ug== X-Received: by 10.157.25.170 with SMTP id k39mr3951643otk.86.1467521330973; Sat, 02 Jul 2016 21:48:50 -0700 (PDT) In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: <85mvm5vrbw.fsf@benfinney.id.au> <21916e7b-9e19-4cef-94e0-bac331540ca2@googlegroups.com> Xref: csiph.com comp.lang.python:110973 On Sat, Jul 2, 2016 at 12:40 AM, Lawrence D=E2=80=99Oliveiro wrote: > On Saturday, July 2, 2016 at 5:10:06 PM UTC+12, Ian wrote: >> You should use functools.wraps instead of clobbering the decorated >> function's name and docstring: > > Where am I doing that? Using the implementation you posted: >>> @decorator_with_args ... def my_decorator(func, *args, **kwargs): ... """Returns func unmodified.""" ... return func ... >>> my_decorator.__doc__ 'generates a decorator which applies my_decorator to the given arguments'