Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #103752 > unrolled thread
| Started by | Chris Angelico <rosuav@gmail.com> |
|---|---|
| First post | 2016-03-01 05:34 +1100 |
| Last post | 2016-03-01 05:34 +1100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: common mistakes in this simple program Chris Angelico <rosuav@gmail.com> - 2016-03-01 05:34 +1100
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2016-03-01 05:34 +1100 |
| Subject | Re: common mistakes in this simple program |
| Message-ID | <mailman.37.1456770890.20602.python-list@python.org> |
On Tue, Mar 1, 2016 at 5:21 AM, Ganesh Pal <ganesh1pal@gmail.com> wrote: > > In my case the exception is nothing but the error example if we plan > to run the command say #ifconfig -a and the command fails because of > a type ( say u ran #igconfig -a). > > we will the output as > > # Failed to run igconfig -a got Error (ret=127) > out : > error: command not found: igconfig > > So the execption is the error i.e Error (ret=127) out : error: command > not found: igconfig, Iam fine with this behaviour. > You're falling into the trap of assuming that the only exception you can ever get is the one that you're planning for, and then handling ALL exceptions as though they were that one. Instead catch ONLY the exception that you're expecting to see, and ignore everything else. Do not use a bare "except:" clause, nor even "except Exception:", for this. You will appreciate it later on. ChrisA
Back to top | Article view | comp.lang.python
csiph-web