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


Groups > comp.lang.python > #84528

Re: Delegation in Python

References <FeCdnXdsTpunvlnJnZ2dnUVZ8judnZ2d@brightview.co.uk> <CAPTjJmoVxi_VXKJ93W=rPNnZiud6O_mXyxm+2tMG8BoQBqH-Ew@mail.gmail.com> <54C42D9D.7010305@digipen.edu> <ma1ble$cn$1@ger.gmane.org>
Date 2015-01-25 11:07 +1100
Subject Re: Delegation in Python
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.18115.1422144482.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Sun, Jan 25, 2015 at 10:59 AM, Mark Lawrence <breamoreboy@yahoo.co.uk> wrote:
>> You can always "monkey-path" the Fraction class on the fly to add a new
>> method to it.  I think most would consider this a bad idea, but it does
>> work.
>
> As regards this being a bad idea I'd suggest the latest score is
> Practicality 1 Purity 0 :)

Indeed. But there's a huge difference between simple and complex
projects. I had a bit of a nightmare trying to figure out what was
going on with a project's logging... it looked like the Python logging
module, but there was another argument being processed, courtesy of
some monkey-patching. Try to keep these changes to small projects,
where it's easier to keep everything in your head; or for a temporary
bit of debugging, where you just want to do this temporarily and then
undo it again when you find the bug. Otherwise, it gets confusing for
the subsequent reader.

ChrisA

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


Thread

Delegation in Python Brian Gladman <noone@nowhere.net> - 2015-01-24 22:57 +0000
  Re: Delegation in Python Chris Angelico <rosuav@gmail.com> - 2015-01-25 10:22 +1100
    Re: Delegation in Python Brian Gladman <noone@nowhere.net> - 2015-01-24 23:38 +0000
      Re: Delegation in Python Chris Angelico <rosuav@gmail.com> - 2015-01-25 10:43 +1100
        Re: Delegation in Python Brian Gladman <noone@nowhere.net> - 2015-01-25 00:18 +0000
          Re: Delegation in Python Chris Angelico <rosuav@gmail.com> - 2015-01-25 11:28 +1100
            Re: Delegation in Python Brian Gladman <noone@nowhere.net> - 2015-01-25 07:49 +0000
              Re: Delegation in Python Chris Angelico <rosuav@gmail.com> - 2015-01-25 19:07 +1100
      Re: Delegation in Python Gary Herron <gherron@digipen.edu> - 2015-01-24 15:47 -0800
        Re: Delegation in Python Brian Gladman <noone@nowhere.net> - 2015-01-24 23:58 +0000
  Re: Delegation in Python Gary Herron <gherron@digipen.edu> - 2015-01-24 15:41 -0800
    Re: Delegation in Python Brian Gladman <noone@nowhere.net> - 2015-01-24 23:52 +0000
  Re: Delegation in Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-01-24 23:59 +0000
  Re: Delegation in Python Chris Angelico <rosuav@gmail.com> - 2015-01-25 11:07 +1100
  Re: Delegation in Python Terry Reedy <tjreedy@udel.edu> - 2015-01-24 20:31 -0500
    Re: Delegation in Python Brian Gladman <noone@nowhere.net> - 2015-01-25 07:43 +0000

csiph-web