[Tutor] what instance type is a function object?

Adam Pridgen atpridgen at mail.utexas.edu
Thu Feb 22 20:35:54 CET 2007

Thanks in advance for your help.
I am trying to pickle a class, but I want to exclude function objects
for obvious reasons.  How do I determine if a python object is a
function, specifically when using isinstance()?  I am not sure what a
type or instance a Python 'function' originates from.

The below code throws an exception, because function is not a type.
Presently I am attempting to do the following:

def __getstate__(
   ret_val = {}
   for key in self.__dict__:
      if not isinstance(self.__dict__[key], function): pass
      # do assignment here

Thanks again, Adam

More information about the Tutor mailing list