Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #24415 > unrolled thread
| Started by | Shambhu Rajak <Shambhu.Rajak@kpitcummins.com> |
|---|---|
| First post | 2012-06-25 05:19 +0000 |
| Last post | 2012-06-25 05:19 +0000 |
| 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: exception problem Shambhu Rajak <Shambhu.Rajak@kpitcummins.com> - 2012-06-25 05:19 +0000
| From | Shambhu Rajak <Shambhu.Rajak@kpitcummins.com> |
|---|---|
| Date | 2012-06-25 05:19 +0000 |
| Subject | RE: exception problem |
| Message-ID | <mailman.1476.1340603387.4697.python-list@python.org> |
If you are not sure about the Exception, You can adopt a generic way of handling exception.
try:
....
except Exception,e:
print str(e)
-Shambhu
-----Original Message-----
From: MRAB [mailto:python@mrabarnett.plus.com]
Sent: 25/06/2012 4:14 AM
To: python-list@python.org
Subject: Re: exception problem
On 24/06/2012 23:26, Charles Hixson wrote:
> The code:
> print ("pre-chunkLine")
> chunks = []
> try:
> chunks = self.chunkLine (l)
> except:
> print ("caught exception")
> print (sys.exc_info()[:2])
> finally:
> print ("at finally")
> print ("chunks =")
> print (repr(chunks), ".", end = ":")
> produces this result:
> . . ., by
> pre-chunkLine
> caught exception
> at finally
> path 3...
>
> Any suggestions as to what's wrong with the code?
> FWIW, chunkLine begins:
> def chunkLine (self, line):
> print ("chunkLine: ")
> print ("line = ", line)
> if line == None:
> return []
> assert (isinstance (line, str) )
>
Don't use a bare "except"; it'll catch _any__exception. Catch only what
you expect.
For all I know, it could be that the name "l" doesn't exist.
Back to top | Article view | comp.lang.python
csiph-web