callable to disappear?

Antoon Pardon apardon at forel.vub.ac.be
Fri Aug 25 03:38:32 EDT 2006


On 2006-08-23, Terry Reedy <tjreedy at udel.edu> wrote:
>
> "faulkner" <faulkner612 at comcast.net> wrote in message 
> news:1156357324.838315.234500 at i42g2000cwa.googlegroups.com...
>> what's wrong with hasattr(obj, '__call__')?
>
> I have the impression that this is not currently true for all callables . 
> If not, this may be improved in the future.
>
>>> Antoon Pardon
>>> Is there a chance this will be reconsidered?
>
> The items in PEP 3100 have different levels of certainly.  Some may even 
> get changed after experience with the alpha versions.  Guido is allowing a 
> year from first alpha (early 2007?) to final release, instead of the 
> current 4-5 months.
>
> There has been recent discussion since of iscallable and some other 
> isxxxx()s.  The points you mentioned were raised and considered.  I don't 
> remember if there was a decision for the present.
>
> Two of the bigger negatives for 'iscallable':
> 1. You cannot know for sure until you call and get a return.

Even that is not sure. Consider the following:

  Bar = 1
  
  def Foo():
    Bar()
  
  try:
      Foo()
  except ...:
      warning("...")


Calling Foo will result in the same exception being raised as if
Foo wasn't callable, while in fact it is callable.

> 2. It does not say if the candidate is callable with any particular number 
> or set of parameters.

But the "raise an exception" option doesn't make this distinction either.
A TypeError will be raised both when the object isn't callable or when
it is called with the wrong parameters.

-- 
Antoon Pardon



More information about the Python-list mailing list