Using decorators with argument in Python

Ethan Furman ethan at stoneleaf.us
Wed Jun 29 17:51:18 EDT 2011


Ian Kelly wrote:
> 
> @enclose
> def test5(string, func):
>      print(func(string))
> test5('broken', func=str.upper)

Yes, that is a limitation -- one loses the func keyword for the 
decorated function.  If I were to actually use this, I'd probably go 
with '_func' as the keyword.

~Ethan~

PS
Thanks for the code review!



More information about the Python-list mailing list