Browse Source

Revert some of my callable changes, I found out that old-style classes don't provide __call__

rdb 15 years ago
parent
commit
7a33157f92

+ 2 - 2
direct/src/http/webAIInspector.py

@@ -351,7 +351,7 @@ class Inspector:
         keys.sort()
         for each in keys:
             self._partsList.append(each)
-            #if not hasattr(getattr(self.object, each), '__call__'):
+            #if not callable(getattr(self.object, each)):
             #    self._partsList.append(each)  
 
     def initializePartNames(self):
@@ -373,7 +373,7 @@ class Inspector:
     def stringForPartNumber(self, partNumber):
         object = self.partNumber(partNumber)
         doc = None
-        if hasattr(object, '__call__'):
+        if callable(object):
             try:
                 doc = object.__doc__
             except:

+ 2 - 2
direct/src/interval/LerpInterval.py

@@ -57,7 +57,7 @@ class LerpNodePathInterval(CLerpNodePathInterval):
         # parameter.
 
         for param in params:
-            if hasattr(param, '__call__'):
+            if callable(param):
                 return 1
         return 0
 
@@ -67,7 +67,7 @@ class LerpNodePathInterval(CLerpNodePathInterval):
         # a callable functor, calls it; otherwise, uses the param
         # directly.
         if param != None:
-            if hasattr(param, '__call__'):
+            if callable(param):
                 func(param())
             else:
                 func(param)

+ 1 - 1
direct/src/interval/ProjectileInterval.py

@@ -106,7 +106,7 @@ class ProjectileInterval(Interval):
         def doIndirections(*items):
             result = []
             for item in items:
-                if hasattr(item, '__call__'):
+                if callable(item):
                     item = item()
                 result.append(item)
             return result

+ 2 - 2
direct/src/showbase/PythonUtil.py

@@ -117,7 +117,7 @@ class Functor:
         _kargs.update(kargs)
         return self._function(*(self._args + args), **_kargs)
 
-    # this methoxd is used in place of __call__ if we are recording creation stacks
+    # this method is used in place of __call__ if we are recording creation stacks
     def _exceptionLoggedCreationStack__call__(self, *args, **kargs):
         try:
             return self._do__call__(*args, **kargs)
@@ -510,7 +510,7 @@ def _pdir(obj, str = None, width = None,
     format = '%-' + repr(maxWidth) + 's'
     for key in keys:
         value = dict[key]
-        if hasattr(value, '__call__'):
+        if callable(value):
             strvalue = repr(Signature(value))
         else:
             strvalue = repr(value)

+ 2 - 2
direct/src/tkpanels/Inspector.py

@@ -88,7 +88,7 @@ class Inspector:
         keys.sort()
         for each in keys:
             self._partsList.append(each)
-            #if not hasattr(getattr(self.object, each), '__call__'):
+            #if not callable(getattr(self.object, each)):
             #    self._partsList.append(each)  
 
     def initializePartNames(self):
@@ -110,7 +110,7 @@ class Inspector:
     def stringForPartNumber(self, partNumber):
         object = self.partNumber(partNumber)
         doc = None
-        if hasattr(object, '__call__'):
+        if callable(object):
             try:
                 doc = object.__doc__
             except: