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


Groups > comp.lang.python > #102877

Re: modifying a standard module?

Path csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail
From Paul Rubin <no.email@nospam.invalid>
Newsgroups comp.lang.python
Subject Re: modifying a standard module?
Date Fri, 12 Feb 2016 16:21:30 -0800
Organization A noiseless patient Spider
Lines 11
Message-ID <87bn7lcved.fsf@nightsong.com> (permalink)
References <n9hgtb$rls$1@news2.informatik.uni-stuttgart.de> <mailman.43.1455187713.22075.python-list@python.org> <n9i07l$vgl$1@news2.informatik.uni-stuttgart.de> <n9i246$vva$1@news2.informatik.uni-stuttgart.de> <n9idk7$37f$1@news2.informatik.uni-stuttgart.de> <n9ifak$3l7$1@news2.informatik.uni-stuttgart.de> <mailman.85.1455310425.22075.python-list@python.org> <n9lnd3$u3c$1@news2.informatik.uni-stuttgart.de>
Mime-Version 1.0
Content-Type text/plain
Injection-Info mx02.eternal-september.org; posting-host="560a36ee31cc4bcf69e115b311f0cc5c"; logging-data="3618"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Ax9Bt9B3uWychoWPY1cA2"
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)
Cancel-Lock sha1:N4+1W0ZoFLkoKt0s0NWP7hb8vZc= sha1:JAdX9y4YcUExssRXdLl96UlAoLk=
Xref csiph.com comp.lang.python:102877

Show key headers only | View raw


Ulli Horlacher <framstag@rus.uni-stuttgart.de> writes:
>> tarfile.TarFile.extractall = new_extractall
>
> This is more easy than I could imagined :-) It is in my Python notes,
> now.

This is called "duck punching" or "monkey patching" and sometimes it's
necessary, but it's something of an antipattern since the module could
change under you between versions, and that sort of thing.  If you have
to do it, then fine; but if you have a choice, it's preferable to avoid
that sort of thing.

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


Thread

tarfile : read from a socket? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2016-02-11 08:31 +0000
  Re: tarfile : read from a socket? INADA Naoki <songofacandy@gmail.com> - 2016-02-11 19:26 +0900
  Re: tarfile : read from a socket? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2016-02-11 11:47 +0100
    Re: tarfile : read from a socket? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2016-02-11 12:53 +0000
      Re: tarfile : read from a socket? MRAB <python@mrabarnett.plus.com> - 2016-02-11 13:16 +0000
      Re: tarfile : read from a socket? Chris Angelico <rosuav@gmail.com> - 2016-02-12 00:18 +1100
        Re: tarfile : read from a socket? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2016-02-11 13:34 +0000
      Re: tarfile : read from a socket? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2016-02-11 13:25 +0000
        Re: tarfile : read from a socket? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2016-02-11 16:41 +0000
          Re: tarfile : read from a socket? MRAB <python@mrabarnett.plus.com> - 2016-02-11 17:10 +0000
          modifying a standard module? (was: Re: tarfile : read from a socket?) Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2016-02-11 17:10 +0000
            Re: modifying a standard module? (was: Re: tarfile : read from a socket?) Matt Wheeler <m@funkyhat.org> - 2016-02-12 20:53 +0000
              Re: modifying a standard module? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2016-02-12 22:46 +0000
                Re: modifying a standard module? Paul Rubin <no.email@nospam.invalid> - 2016-02-12 16:21 -0800
          Re: tarfile : read from a socket? Peter Otten <__peter__@web.de> - 2016-02-11 18:18 +0100
          Re: tarfile : read from a socket? Lars Gustäbel <lars@gustaebel.de> - 2016-02-11 18:27 +0100
          Re: tarfile : read from a socket? Random832 <random832@fastmail.com> - 2016-02-11 16:23 -0500
          Re: tarfile : read from a socket? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2016-02-12 09:35 +0100
          Re: tarfile : read from a socket? Lars Gustäbel <lars@gustaebel.de> - 2016-02-12 09:40 +0100
            Re: tarfile : read from a socket? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2016-02-12 12:48 +0000

csiph-web