Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!rt.uk.eu.org!feed.xsnews.nl!border-2.ams.xsnews.nl!feeder1.cambriumusenet.nl!feed.tweaknews.nl!194.134.4.91.MISMATCH!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'case.': 0.05; 'modify': 0.05; 'lines.': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'terry': 0.09; 'latter,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'so)': 0.16; 'specified.': 0.16; 'subject:patch': 0.16; 'subject:possible': 0.16; 'wrote:': 0.17; 'jan': 0.18; '(or': 0.18; 'patch': 0.24; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'leave': 0.26; 'am,': 0.27; 'is?': 0.27; 'header:X-Complaints-To:1': 0.28; 'chris': 0.28; 'marc': 0.29; 'omitted': 0.29; 'piece': 0.29; 'subject:like': 0.29; 'code': 0.31; 'to:addr:python-list': 0.33; 'subject:?': 0.35; 'received:org': 0.36; 'method': 0.36; 'two': 0.37; 'subject:: ': 0.38; 'copying': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'most': 0.61; 'gave': 0.65; 'subject:this': 0.84; 'received:fios.verizon.net': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Is it possible monkey patch like this? Date: Tue, 18 Dec 2012 11:49:07 -0500 References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-173-75-251-66.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20121026 Thunderbird/16.0.2 In-Reply-To: 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: 13 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1355849362 news.xs4all.nl 6843 [2001:888:2000:d::a6]:45650 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:35063 On 12/18/2012 5:26 AM, Marc Aymerich wrote: > I want to monkey patch a method that has lots of code so I want to > avoid copying all the original method for changing just two lines. You omitted the most important piece of information. Can you modify the original code (or get someone else to do so) or must you leave it as is? Chris and Peter gave you answers for the former case. If the latter, you must copy and modify for the change you specified. -- Terry Jan Reedy