passing no arguments to a callback function question
Duncan Booth
duncan at NOSPAMrcp.co.uk
Tue Apr 8 06:31:37 EDT 2003
More information about the Python-list mailing list
Tue Apr 8 06:31:37 EDT 2003
- Previous message (by thread): Embedded MacPython in a Multi-Threaded App
- Next message (by thread): passing no arguments to a callback function question
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
matthew <matthew at newsgroups.com> wrote in news:b6u60i$i6p$1 at lust.ihug.co.nz: > Thanks for the hint. However, functions like print_params are outside of > the class scope sitting in another module. The idea is that users can > write their own functions which they can add as listeners for certain > event types being scanned from a file. I 'pinched' the curry class from > the py.cookbook and I think I'm probably being tripped up by my only > vague understanding of argument passing. Here is the listener code > (which I'm sure must look pretty ugly to you guys):-. Thanks for further > assistance. matthew. > entry = (function, self.curry(function,args)) This passes an argument of None which will then be passed on to your function when it is called. You need to pass an empty sequence if you want your function to take no arguments. Also it looks as though you want to unpack a tuple 'args' into the *args argument to curry, which means you need to use the star on the call as well. Try: if args is None: args = () entry = (function, self.curry(function, *args)) or you could set the default argument to () instead of None for a similar effect. -- Duncan Booth duncan at rcp.co.uk int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
- Previous message (by thread): Embedded MacPython in a Multi-Threaded App
- Next message (by thread): passing no arguments to a callback function question
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list