On 20 February 2013 17:54, <mikp...@gmail.com> wrote: > On Tuesday, February 19, 2013 5:47:16 PM UTC, Michael Torrie wrote: >> On 02/19/2013 02:24 AM, mikp...@gmail.com wrote: >> >> > Or rather: what would you try to catch in this particular case? >> >> >> As Peter said, nothing for now. But you seem very resistant to telling >> >> us what exception was raised. > > > Michael believe me: > I am not resistant or try to hide anything! > As written before, I don't know what exception to search for, so I wrote the > (wrong) code: > except: > print "error" > Let's why I don't have a clue about it. > But someone already explained me that I should not do this.
You don't need to look for errors. If you remove the try/except then they show up automatically. For example (in the interpreter): $ python Python 2.7.3 (default, Sep 26 2012, 21:51:14) [GCC 4.7.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> open('Desktop') Traceback (most recent call last): File "<stdin>", line 1, in <module> IOError: [Errno 21] Is a directory: 'Desktop' The last three lines above are the error message that people were expecting you to show here. They contains lots of useful information: 1) The type of the error 2) A message "Is a directory" and in this case a cryptic code 21 (that some might find useful). 3) The line of code that caused the error (this is more useful when running code saved in a file). What you are doing, however, is this: >>> try: ... open('Desktop') ... except: ... print('An error occurred...') ... An error occurred... Which gives a much less useful error message. So just remove the try/except. Oscar -- http://mail.python.org/mailman/listinfo/python-list