[Python-ideas] Fix that broken callable builtin
Chris Angelico
rosuav at gmail.com
Sat Apr 18 23:10:58 CEST 2015
On Sun, Apr 19, 2015 at 2:33 AM, Ionel Cristian Mărieș
<contact at ionelmc.ro> wrote:
> On Sat, Apr 18, 2015 at 3:25 PM, Chris Angelico <rosuav at gmail.com> wrote:
>>
>> Is it intentional that
>> property-getter functions can raise AttributeError to signal that the
>> attribute does not (currently) exist? Because if that's a hack, then
>> there's no reason to support it, and callable() is absolutely correct
>> to say "there is a __call__ attribute on the class, ergo it's
>> callable".
>
>
> It's hard to say what's intended or not. At best is speculation, as
> python-the-language does not have a specification.
That's not true; there is a spec for the language, which is
independent of CPython, PyPy, etc, which are the implementations of
it. There are times when the spec is less than clear, which are often
flagged by someone coming to python-dev saying "I'm trying to add
Feature X to SomePython, and I'm not sure whether this is how it
should be done or not - that's how CPython does it", and then the
answer to that question becomes a language spec improvement.
But in this case, the question isn't one of Python vs CPython, but one
of the use of application-level code. If this is considered a hack,
then it's not part of the language spec at all, but if it's deemed a
feature, then (a) every Python implementation will be required to
match it, and (b) other parts of the language (in this case,
callable()) will probably be required to acknowledge it.
ChrisA
More information about the Python-ideas
mailing list