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


Groups > comp.lang.python > #44312

Re: epiphany

Date 2013-04-24 19:25 -0700
From Ethan Furman <ethan@stoneleaf.us>
Subject Re: epiphany
References <roy-23D9FA.19503324042013@news.panix.com> <5178884b$0$29977$c3e8da3$5496439d@news.astraweb.com>
Newsgroups comp.lang.python
Message-ID <mailman.1045.1366857991.3114.python-list@python.org> (permalink)

Show all headers | View raw


On 04/24/2013 06:35 PM, Steven D'Aprano wrote:
> Objects are supposed to return NotImplemented from special dunder methods
> like __add__, __lt__, etc. to say "I don't know how to implement this
> method for the given argument". Python will then try calling the other
> object's special method. If both objects return NotImplemented, Python
> falls back on whatever default behaviour is appropriate.
>
> So, knowing nothing of your application, I fear that this is an abuse of
> NotImplemented's semantics. If a rule returns NotImplemented, I would
> expect your application to fall back on a different rule. If that's not
> the case, you're using it in a non-standard way that will cause confusion
> for those with expectations of what NotImplemented means.

Why would you assume some random application is going to deal with NotImplemented the same way the python interpreter 
does?  And even the interpreter isn't consistent -- sometimes it will return false (__eq__) and sometimes it will raise 
an Exception (__add__).

I hardly think it an abuse of NotImplemented to signal something is not implemented when NotImplemented means, um, not 
implemented.

possibly-not-implemented-ly yours,

--
~Ethan~

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


Thread

epiphany Roy Smith <roy@panix.com> - 2013-04-24 19:50 -0400
  Re: epiphany Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-25 01:35 +0000
    Re: epiphany Roy Smith <roy@panix.com> - 2013-04-24 21:41 -0400
      Re: epiphany Chris Angelico <rosuav@gmail.com> - 2013-04-25 12:20 +1000
        Re: epiphany Roy Smith <roy@panix.com> - 2013-04-24 22:33 -0400
      Re: epiphany Ethan Furman <ethan@stoneleaf.us> - 2013-04-24 19:28 -0700
    Re: epiphany Ethan Furman <ethan@stoneleaf.us> - 2013-04-24 19:25 -0700
      Re: epiphany Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-25 04:32 +0000
        Re: epiphany Roy Smith <roy@panix.com> - 2013-04-25 08:36 -0400
          Re: epiphany Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-25 12:52 +0000
            Re: epiphany Roy Smith <roy@panix.com> - 2013-04-25 09:15 -0400
  Re: epiphany 88888 Dihedral <dihedral88888@googlemail.com> - 2013-04-28 14:14 -0700

csiph-web