Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail 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; 'socket': 0.07; 'dan': 0.09; 'subject:method': 0.09; 'cc:addr:python-list': 0.11; '"list': 0.16; 'finney': 0.16; 'merely': 0.16; 'operation,': 0.16; 'simple.': 0.16; 'subject:class': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'example': 0.22; 'putting': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'skip:" 30': 0.26; 'header:In-Reply-To:1': 0.27; 'feature': 0.29; 'message- id:@mail.gmail.com': 0.30; 'writes:': 0.31; 'class': 0.32; 'probably': 0.32; '(i.e.': 0.33; 'actual': 0.34; "i'd": 0.34; 'subject:with': 0.35; 'connection': 0.35; 'operations': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'subject:one': 0.36; 'useful': 0.36; "i'll": 0.36; 'subject:?': 0.36; 'operating': 0.37; 'ben': 0.38; 'configured': 0.38; 'simple': 0.61; 'making': 0.63; 'improvement': 0.84; 'why?': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=EskVnUUHgSffFJmjn7S164a0m+3LQ3Gj4E0qK4NbMZ4=; b=Q158nJSk1/I6CasHuSwlvGsKWrpuC9H9jS3iEWWoA0HqHNB/f4WdAYWNekyCue9qrS TYlIgi0KOrOFY7Ut6Vcs2cgDGi/qCnPGbEbMj7dUA/WRmszcm2F+CqnVgLgtBy2gv1Nv uJur+GlZFtiPQgjVmV1kRXQKHvITKSrjEz833FJQ6TAzeRlQEw4rkeBX5jRz861JDuWf wnRx9eN3m6KQdaeY5KsHYlqM91q31Qz9KzepW7R1xi1lF6qb8DyX32HatYRuLy0zwvKq VBhndS76iTQ/jQbChSjKARmnWJZ6YsjjkBzpzho1snNcdFVUPPIXX597flbmT9WX0Wu0 33wQ== MIME-Version: 1.0 X-Received: by 10.236.191.132 with SMTP id g4mr7358642yhn.32.1402250655219; Sun, 08 Jun 2014 11:04:15 -0700 (PDT) In-Reply-To: <85lht91s30.fsf@benfinney.id.au> References: <85lht91s30.fsf@benfinney.id.au> Date: Sun, 8 Jun 2014 11:04:15 -0700 Subject: Re: Decorating one method of a class C with another method of class C? From: Dan Stromberg To: Ben Finney Content-Type: text/plain; charset=UTF-8 Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1402251131 news.xs4all.nl 2899 [2001:888:2000:d::a6]:53877 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:72989 On 6/6/14, Ben Finney wrote: > Dan Stromberg writes: > >> Is there a way of decorating method1 of class C using method2 of class >> C? > > Can you give a concrete example (i.e. not merely hypothetical) where > this would be a useful feature (i.e. an actual improvement over the > absence of the feature), and why? I have a class that's operating on a socket. I'd like to have simple operations on that socket like "list configured hosts", "allow connection to host", etc. And I'd like them to be decorated with "reconnected_to_server_if_needed". I'll probably end up putting a try/except in each simple operation, making them a bit less simple.