[Tutor] Resuming one block of code continuously after exception in try/except construction

Alan Gauld alan.gauld at btinternet.com
Mon Jul 7 01:31:37 CEST 2014


On 06/07/14 22:00, Ali Mammadov wrote:

> BTW, I created a small gist located here
> <https://gist.github.com/bca59570ea5fd365c672> which demonstrates my
> problem.

I forgot one other thing...

-----------------
def makelgpwdcombs(brutelistname):
     try:
	blst = open(brutelistname, 'r')
     except:
	print("[-] Invalid file name or insufficient priviliges")--


Don't use a bare except here./ catch the specific errror(s) you expect 
to get. In this case its probably IOError...

Then any unexpected errors will generate a stacktrace and not a 
confusing (and wrong) error message



Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos



More information about the Tutor mailing list