On Apr 4, 1:57 pm, John Nagle <na...@animats.com> wrote: > If you want functions with state, use an object. That's what they're > for. Don't muck with the internal representation of functions. >
While "Don't muck with the internal representation of functions" is excellent advice over 99% of the time, it is also true that it is often possible, sometimes even encouraged, to have "functions with state." This is done without "mucking" and without explicitly declaring a class or a class instance. See, e.g. closures and generator functions. Regards, Pat -- http://mail.python.org/mailman/listinfo/python-list