Generators and Decorators doing my head in ..

2005-09-06 Thread simonvc
Hi Can someone please help me understand this (i shouldn't have tried to learn decorators and generators at the same time..). Im trying to create a decorator that counts the number of times a function is run. Somthing like: def FunctionCounter(): n=0 while 1: yield n n=n+

Re: Generators and Decorators doing my head in ..

2005-09-06 Thread simonvc
Fantastic, thanks Leif and Paul, My problem is that i thought the decorator worked at the function runtime, not when the function gets created. -- http://mail.python.org/mailman/listinfo/python-list