how to count lines in a file ?

Donn Cave donn at drizzle.com
Sat Jul 27 21:14:44 EDT 2002


Quoth bokr at oz.net (Bengt Richter):
...
| I like this, but I think I would rather see timely finalization
| subsumed under a general event-handling mechanism for objects. Thus
| ref count going to zero would be a standard event that you could
| write a handler for. A rack of event handlers might be specified
| much like __slots__, except a list of tuples instead of names,
| (could use a dict, but might want to specify piority order to
| put likely events first) e.g., (using a fictional container for
| standard platform event, perhaps extendable a la sys.modules):
|
| class Foo:
|     __events__ = [(sys.events.ON_ZERO_REFCOUNT, myFinalize)}
|     ...
|     def myFinalize(self, event, *rest):
|        self.f.close()

This function could also say "no", if you wanted to give the
object the option to survive zero refcount.

	Donn Cave, donn at drizzle.com



More information about the Python-list mailing list