[Python-Dev] 'hasattr' is broken by design

Guido van Rossum guido at python.org
Mon Aug 23 22:55:10 CEST 2010


On Mon, Aug 23, 2010 at 1:50 PM, Raymond Hettinger
<raymond.hettinger at gmail.com> wrote:
>
> On Aug 23, 2010, at 1:45 PM, Benjamin Peterson wrote:
>
> > 2010/8/23 Raymond Hettinger <raymond.hettinger at gmail.com>:
> >>
> >> P.S.  The current behavior seems to be deeply embedded:
> >
> > Well, that's what happens when a behavior is added in 1990. :)
>
> More generally:  it is an API code smell whenever documentation
> promises something like "this always succeeds"     ;-)

Changing C APIs is even harder than changing Python API because you
can't add exceptions to something that wasn't returning exceptions
before. We did that for comparisons in the past and it was a pain (but
worth it). For these two little APIs I think it is not worth it,
though it may be worth it to create new APIs that *do* return
exceptions.

--
--Guido van Rossum (python.org/~guido)


More information about the Python-Dev mailing list