On Sat, Aug 6, 2011 at 4:10 AM, David Townshend <[email protected]>wrote:
>
> def counter(add) as func:
> if not hasattr(func, 'count'):
> func.count = 0
> func.count += 1
> print(func.count)
>
You already can do that without an as statment.
>>> def counter(add):
if not hasattr(counter, 'count'):
counter.count = 0
counter.count += 1
return counter.count
>>> counter('You ever notice how this parameter is never used anyway?')
Output: 1
>>> counter('Oh well')
Output: 2
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor