Changeset 2821


Ignore:
Timestamp:
Jul 20, 2010 1:46:14 PM (9 years ago)
Author:
prsteel
Message:

Added isfunctor, which returns True iff its one argument is callable.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • coopr.pyomo/trunk/coopr/pyomo/base/util.py

    r2786 r2821  
    171171    return xrange(args[0],args[1]+1,args[2])
    172172
     173def isfunctor(obj):
     174    """
     175    Returns true iff obj.__call__ is defined.
     176    """
     177    try:
     178        obj.__call__
     179        return True
     180    except:
     181        return False
Note: See TracChangeset for help on using the changeset viewer.