Andrew Bennetts andrew-pythonlist at
Wed Feb 26 02:36:43 CET 2003

On Tue, Feb 25, 2003 at 04:36:53PM -0800, Erik Max Francis wrote:
> Jeremy Yallop wrote:
> > I find staticmethod()'s behaviour a bit surprising.  In particular:
> > 
> > Why does staticmethod() `work' on uncallable objects?
> > 
> >   >>> staticmethod('huh?')
> >   <staticmethod object at 0x8152eb8>
> > 
> > I'd expect this to raise an exception.
> staticmethod just creates a wrapper.  It doesn't check whether the
> object in question is callable since Python is dynamic and, when passed
> arbitrary objects, it's not trivial to tell whether the object is
> callable unless you actually try calling it (and see if it fails).  In
> other words, Python gives you the benefit of the doubt and supposes you
> know what you're doing.

Minor correction: it *is* trivial to tell if something is callable.  Just do


More information about the Python-list mailing list