On 2006-08-23, Terry Reedy <[EMAIL PROTECTED]> wrote:
>
> "faulkner" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
>> 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
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to