opposite of __init__.py
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Mon Aug 19 13:13:38 EDT 2013
On Mon, 19 Aug 2013 18:48:19 +0200, Tamer Higazi wrote:
> Hi people!
>
> I have asked myself a question, if there is a opposite of "__init__.py"
> like "__del__.py" ?!
No. If you want to run code when your application is shutting down, run
it just before your code finishes:
def main():
do_this()
do_that()
if __name__ == '__main__':
main()
shutdown()
If you care about code running even if an exception takes place:
if __name__ == '__main__':
try:
main()
finally:
shutdown()
--
Steven
More information about the Python-list
mailing list