"Craig McDonald" <craig.a....@googlemail.com> wrote

try:
   statements
   extractData()
   more_statements
   even_more_statements
except KeyboardInterrupt:
   exit('Exiting')

Once it enters/runs the extractData func and if I choose to exit
(control c) it throws an exception rather than exiting cleanly. Do I
need to put a 'KeyboardInterrupt' exception for every function?

It should work as you've shown.
What should happen is that if you type Ctrl-C while the script is executing extractData() then Python will raise the exception and the function will not know what to do with it, so it raises it to the next level where your handler should catch it.

So what does your real handler look like?

And what does the exception that is raised look like?

HTH


--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to