[Python-3000] try ... then ... then ... except / finally

Fredrik Lundh fredrik at pythonware.com
Thu Oct 12 11:18:29 CEST 2006


Antoine wrote:

> I thought it would be nice to have an idiom where several blocks of code
> are tried in order, regardless of whether they throw an exception or not:
>
> try:
>    self.db_transaction.commit()
> then:
>    self.tmpoutfile.close()
> then:
>    self.destroy_shared_memory_handle()
> except Exception, e:
>    logging.error("an exception occurred in cleanup: %s", e)

that's spelled "with nested" in Python 2.5.  see:

    http://docs.python.org/whatsnew/pep-343.html

</F> 





More information about the Python-3000 mailing list