Hi all, not exactly a django question but here goes... I'm trying to implement a decorator with one positional argument and one keyword argument. My wrapper function gets the positional argument just fine but the keyword argument throws an error "NameError: name 'as_string' is not defined."
Code is; def widget(widget_switch, as_string=False): def decorator(func): def wrapper(*args, **kwargs): # logic in here can access the value of 'widget_switch' but 'as_string' is not defined? return func(*args, **kwargs) return wrapper return decorator So if I decorate a view function with "@widget('some_widget', as_string=True)" then the wrapper function is unable to use 'as_string'. I thought this was how python closer worked? Any ideas? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.