Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Matt Wheeler Newsgroups: comp.lang.python Subject: Re: monkey patching __code__ Date: Mon, 21 Mar 2016 20:42:36 +0000 Lines: 21 Message-ID: References: <56EBEB5A.7050207@mail.de> <56EED3DE.7050101@mail.de> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de ZUgQ9yAk6SKn+UhiSa5b6Q6+Attpg0XH4iUazfoP+Diw== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.049 X-Spam-Evidence: '*H*': 0.90; '*S*': 0.00; 'defaults': 0.05; 'imported': 0.09; '2016': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'to:name:python list': 0.16; 'wrote:': 0.16; 'explicit': 0.22; 'function,': 0.22; 'suppose': 0.22; 'code.': 0.23; 'seems': 0.23; 'header:In-Reply-To:1': 0.24; 'updating': 0.27; 'message-id:@mail.gmail.com': 0.27; 'function': 0.28; 'code': 0.30; 'received:google.com': 0.35; 'quite': 0.35; 'but': 0.36; 'received:209.85': 0.36; 'modules': 0.36; 'to:addr :python-list': 0.36; 'subject:: ': 0.37; 'received:209': 0.38; 'someone': 0.38; 'end': 0.39; 'why': 0.39; 'to:addr:python.org': 0.40; 'your': 0.60; 'skip:u 10': 0.61; 'more': 0.63; 'march': 0.64; 'from:addr:m': 0.84; 'injecting': 0.84 X-Virus-Scanned: Debian amavisd-new at membrane.funkyhat.net X-Gm-Message-State: AD7BkJLjzsSIDDm4SPG0zM0QsM0GQcY6IKa11W2NSgdO745PO0dorAxzTO0USMNmTZwE5UVyVZeVz39SW4Z+1Q== X-Received: by 10.112.47.232 with SMTP id g8mr9271549lbn.55.1458592976311; Mon, 21 Mar 2016 13:42:56 -0700 (PDT) In-Reply-To: <56EED3DE.7050101@mail.de> X-Gmail-Original-Message-ID: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 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:105406 On 20 March 2016 at 16:46, Sven R. Kunze wrote: > On 19.03.2016 00:58, Matt Wheeler wrote: >> >> I know you have a working solution now with updating the code & >> defaults of the function, but what about just injecting your function >> into the modules that had already imported it after the >> monkeypatching? >> >> Seems perhaps cleaner, unless you'd end up having to do it to lots of >> modules... > > Why do you consider it cleaner? I think it would be more explicit and understandable for someone reading your code. I suppose it's quite subjective :) -- Matt Wheeler http://funkyh.at