Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: "Sven R. Kunze" Newsgroups: comp.lang.python Subject: Re: monkey patching __code__ Date: Fri, 18 Mar 2016 15:32:09 +0100 Lines: 19 Message-ID: References: <56EBEB5A.7050207@mail.de> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 9riEVGVmtsuqoKH16hcpkwe3bOV/QBB7C1MpWpAtwr/w== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.029 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'defaults': 0.05; 'suggestions.': 0.09; 'template': 0.11; ':-)': 0.12; 'django': 0.13; 'attribute?': 0.16; 'better:': 0.16; 'function?': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'featured': 0.18; 'do.': 0.22; 'trying': 0.22; 'header:In-Reply- To:1': 0.24; 'function': 0.28; 'lot.': 0.29; 'code': 0.30; 'another': 0.32; 'especially': 0.32; 'surely': 0.33; 'open': 0.33; 'received:10.0': 0.34; 'add': 0.34; 'best,': 0.35; 'but': 0.36; 'there': 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; 'to:addr:python.org': 0.40; 'received:de': 0.40; 'some': 0.40; 'your': 0.60; 'charset:windows-1252': 0.62; 'our': 0.64; 'it!': 0.64; 'reverse': 0.66; 'behaviors': 0.72; 'sounds': 0.76 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mail.de; s=mail201212; t=1458311530; bh=P4fo7Vb1zryN8gGQv9e2n1eIWtWNlKFehX83CiifQMM=; h=Subject:To:References:From:Date:In-Reply-To:From; b=uys7tX0xtmGYV3k+/SM/QWUzvgARU+hNkeBUW6p4Kcpz3OVCb11ImQOtM/fKt0WiB HkC2eRDBg6qUHCPtYXAQCR5f3n4gYIO28IUvKXr/4rx2hSdM6FBKX70COxw4NDYUeG XYimgvugySYl5p7QmmRSZ93gfOAWa3AjeySnT6VA= In-Reply-To: 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: 728 X-purgate-ID: 154282::1458311529-000018ED-7BA0699C/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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:105219 On 18.03.2016 14:47, Ian Kelly wrote: > Your patched version takes two extra arguments. Did you add the > defaults for those to the function's __defaults__ attribute? That's it! :-) Thanks a lot. Just to understand this better: why is that not part of the code object but part of the function? > This sounds like a pretty hairy thing that you're trying to do. Surely > there must be some better way to accomplish the same goal. We are open for suggestions. We featured our own reverse function for a while but it lead to inconsistent behaviors across the field. Especially considering that Django provides an {% url %} template tag which would then use yet another reverse implementation. Best, Sven