Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #105406

Re: monkey patching __code__

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Matt Wheeler <m@funkyhat.org>
Newsgroups comp.lang.python
Subject Re: monkey patching __code__
Date Mon, 21 Mar 2016 20:42:36 +0000
Lines 21
Message-ID <mailman.463.1458592985.12893.python-list@python.org> (permalink)
References <56EBEB5A.7050207@mail.de> <CAG93HwGKrN8y3k=3OFtHq-PbMjFzy=1U99-ZuJOLdEq69gosfg@mail.gmail.com> <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 <m@funkyhat.org>
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 <CAG93HwFr-yFqjex_U4yZs5WUuLCCbCJDJfso2Kp6G0F3BdKOZQ@mail.gmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.21
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:105406

Show key headers only | View raw


On 20 March 2016 at 16:46, Sven R. Kunze <srkunze@mail.de> 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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: monkey patching __code__ Matt Wheeler <m@funkyhat.org> - 2016-03-21 20:42 +0000

csiph-web