简体   繁体   中英

python. pass function with some parameters specified

I need pass function to another function with some parameters specified. So half of parameters I need assign before passing function and other parameters would be given inside another function. How to do that?

This is exactly what functools.partial does. For example:

other_function(callback=functools.partial(the_other_function, param1='foo', param2='bar'))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM