Alex Popescu a écrit : > Bruno Desthuilliers <[EMAIL PROTECTED]> wrote in > news:[EMAIL PROTECTED]: (snip) >> if hasattr(obj, '__call__'): >> # it's a callable >> >> but I don't find it so Pythonic to have to check for a __magic__ >> method. > > It looks like Python devs have decided it is Pythonic, because it is > already in the PEP.
I do know, and I disagree with this decision. FWIW, repr(obj) is mostly syntactic sugar for obj.__repr__(), getattr(obj, name) for obj.__getattr__(name), type(obj) for obj.__class__ etc... IOW, we do have a lot of builtin functions that mostly encapsulate calls to __magic__ methods, and I definitively don't understand why this specific one (=> callable(obj)) should disappear. I usually have lot of respect for Guido's talent as a language designer (obviously since Python is still MFL), but I have to say I find this particular decision just plain stupid. Sorry. -- http://mail.python.org/mailman/listinfo/python-list