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


Groups > comp.lang.python > #105220

Re: monkey patching __code__

Path csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From "Sven R. Kunze" <srkunze@mail.de>
Newsgroups comp.lang.python
Subject Re: monkey patching __code__
Date Fri, 18 Mar 2016 15:33:34 +0100
Lines 14
Message-ID <mailman.323.1458311618.12893.python-list@python.org> (permalink)
References <56EBEB5A.7050207@mail.de> <CALwzid=XVSnSEt14Oer-2dO-0kT+fLi1EP4mNehXc0+zDqTX=g@mail.gmail.com> <CALwzidkyyQRSDPbthjKi4YDBtGGZe7M8J1LOA5PjzAn+qk8skg@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 7bit
X-Trace news.uni-berlin.de 8Djsh6bQuSBXLJ+pP/y5Fg3XUFNpIOz7fU05YAXwpEsA==
Return-Path <srkunze@mail.de>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.035
X-Spam-Evidence '*H*': 0.93; '*S*': 0.00; 'defaults': 0.05; 'attributes': 0.07; ':-)': 0.12; '2016': 0.16; 'attribute?': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'am,': 0.23; 'header:In-Reply-To:1': 0.24; 'sense': 0.26; 'fri,': 0.27; 'function': 0.28; 'code': 0.30; 'received:10.0': 0.34; 'add': 0.34; 'best,': 0.35; 'replace': 0.35; 'but': 0.36; 'to:addr :python-list': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'two': 0.37; 'thanks': 0.37; 'version': 0.38; 'why': 0.39; 'takes': 0.39; 'well.': 0.40; 'to:addr:python.org': 0.40; 'received:de': 0.40; 'your': 0.60; "you'll": 0.61; 'charset:windows-1252': 0.62; 'mar': 0.65
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/simple; d=mail.de; s=mail201212; t=1458311615; bh=vceojng0EpOr8+4ACWnI6fOxsUymDcYhbz37UX7vs+E=; h=Subject:To:References:From:Date:In-Reply-To:From; b=iTYGiVvDPfVpeeLeiCPcZIEY/N0pFWTL3qlMAqwhU4gE9CaQPkV+Rofak8DpWPg1t PRzKfB1xtRncZB3AnAaxvj8cjlV834shghHrPlGCR18+q1KCoyO01azrCN0eSricv5 CvOaNrImPT7SwSck4soD9uAeV3jgM7OHWbCXn0GA=
In-Reply-To <CALwzidkyyQRSDPbthjKi4YDBtGGZe7M8J1LOA5PjzAn+qk8skg@mail.gmail.com>
X-purgate clean
X-purgate This mail is considered clean (visit http://www.eleven.de for further information)
X-purgate-type clean
X-purgate-Ad Categorized by eleven eXpurgate (R) http://www.eleven.de
X-purgate This mail is considered clean (visit http://www.eleven.de for further information)
X-purgate clean
X-purgate-size 514
X-purgate-ID 154282::1458311615-000018ED-E12B457A/0/0
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:105220

Show key headers only | View raw


On 18.03.2016 15:23, Ian Kelly wrote:
> On Fri, Mar 18, 2016 at 7:47 AM, Ian Kelly <ian.g.kelly@gmail.com> wrote:
>> Your patched version takes two extra arguments. Did you add the
>> defaults for those to the function's __defaults__ attribute?
> And as an afterthought, you'll likely need to replace the function's
> __globals__ with your own as well.

Thanks again. :-)

Again, why would it make sense for those dunder attributes to be part of 
the function but not of the code object?

Best,
Sven

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


Thread

Re: monkey patching __code__ "Sven R. Kunze" <srkunze@mail.de> - 2016-03-18 15:33 +0100
  Re: monkey patching __code__ Ned Batchelder <ned@nedbatchelder.com> - 2016-03-18 11:01 -0700

csiph-web