On 2/15/2012 8:12 AM, Andrea Crotti wrote:
I have the following very simplified situation
from atexit import register
def goodbye(): print("saying goodbye")
def main():
> while True: var = raw_input("read something")
if __name__ == '__main__':
> register(goodbye)
> main()
But in my
Another option is to use a global error flag and set it in sys.excepthook (see
http://docs.python.org/library/sys.html#sys.excepthook).
goodbye will check the error flag and skip execution if error flag is set.
--
http://mail.python.org/mailman/listinfo/python-list
On 02/15/2012 03:18 PM, Thomas Rachel wrote:
Wouldn't
if __name__ == '__main__':
try:
main()
finally:
goodbye()
be even better? Or doesn't it work well together with SystemExit?
Thomas
Well in that case goodbye is always called, even if I have some other
nasty exce
Am 15.02.2012 14:52 schrieb Devin Jeanpierre:
On Wed, Feb 15, 2012 at 8:33 AM, Mel Wilson wrote:
The usual way to do what you're asking is
if __name__ == '__main__':
main()
goodbye()
and write main so that it returns after it's done all the things it's
supposed to do. If you've sprin
On 02/15/2012 01:52 PM, Devin Jeanpierre wrote:
On Wed, Feb 15, 2012 at 8:33 AM, Mel Wilson wrote:
The usual way to do what you're asking is
if __name__ == '__main__':
main()
goodbye()
and write main so that it returns after it's done all the things it's
supposed to do. If you've spr
On Wed, Feb 15, 2012 at 8:33 AM, Mel Wilson wrote:
> The usual way to do what you're asking is
>
> if __name__ == '__main__':
> main()
> goodbye()
>
> and write main so that it returns after it's done all the things it's
> supposed to do. If you've sprinkled `sys.exit()` all over your code,
Andrea Crotti wrote:
> I have the following very simplified situation
>
> from atexit import register
>
>
> def goodbye():
> print("saying goodbye")
>
>
> def main():
> while True:
> var = raw_input("read something")
>
>
> if __name__ == '__main__':
> register(goodby
I have the following very simplified situation
from atexit import register
def goodbye():
print("saying goodbye")
def main():
while True:
var = raw_input("read something")
if __name__ == '__main__':
register(goodbye)
main()
But in my case the "goodbye" function is