Yeah it's really odd. Since I posted I did the test that you've just
shown and it's works fine. As soon as I put the same decorator on a
django view function the as_string parameter is not defined in the
wrapper. It's baffled me!
On Apr 6, 10:48 am, Jonathan S wrote:
> Your code looks perfect.
Your code looks perfect. Following does print 'True'.
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?
print as_string
Hi cootetom,
For decorators you must have a look at the excellent articles/tutorials:
http://www.artima.com/weblogs/viewpost.jsp?thread=240808
http://www.artima.com/weblogs/viewpost.jsp?thread=240845
It covers decorators with (what you want to do) and without parameters.
Regards
3 matches
Mail list logo