-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Labels
Description
nifty little module!
Would it be possible to support callables instead of just functions - I ran into this use case:
class FuncToolsTest( unittest.TestCase ):
def test( self ):
def f( a, b ):
logging.info( 'a: %s b: %s' % ( repr( a ), repr( b ) ) )
g = functools.partial( f, 'a' )
g('b')
def fp( a, **kwargs ):
logging.info( 'a: %s kwargs: %s' % ( repr( a ), repr( kwargs ) ) )
gp = functools.partial( fp, 'a' )
gp( b = 'b', c = 'c' )
s = signalslot.Signal()
s.connect( gp )
s.emit()
Basically I wanted to specialize a signal handler from a generic function with a partial application in between. Error is:
INFO:root:a: 'a' b: 'b'
INFO:root:a: 'a' kwargs: {'c': 'c', 'b': 'b'}
E..
======================================================================
ERROR: test (main.FuncToolsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "main.py", line 1410, in test
s.connect( gp )
File "lib/signalslot/signal.py", line 57, in connect
if inspect.getargspec(slot).keywords is None:
File "/usr/lib/python2.7/inspect.py", line 816, in getargspec
raise TypeError('{!r} is not a Python function'.format(func))
TypeError: <functools.partial object at 0x7fe65f4889f0> is not a Python function
Reactions are currently unavailable