Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #24415

RE: exception problem

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <Shambhu.Rajak@kpitcummins.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'exception': 0.05; 'mrab': 0.05; 'finally:': 0.07; 'none:': 0.07; '(self,': 0.09; 'except:': 0.09; 'exception,': 0.09; 'exception.': 0.09; 'try:': 0.09; 'def': 0.11; 'chunks': 0.16; 'code?': 0.16; 'exist.': 0.16; 'from:addr:kpitcummins.com': 0.16; 'from:addr:shambhu.rajak': 0.16; 'from:name:shambhu rajak': 0.16; 'line)': 0.16; 'received:169.254.2': 0.16; 'received:59.163': 0.16; 'received:59.163.77': 0.16; 'received:kpit.com': 0.16; 'str)': 0.16; 'subject:exception': 0.16; 'wrote:': 0.17; 'message-----': 0.18; 'received:10.3': 0.22; 'subject:problem': 0.22; 'to:name :python-list@python.org': 0.23; 'header:In-Reply-To:1': 0.23; 'print': 0.25; 'received:169.254': 0.27; 'generic': 0.27; "doesn't": 0.28; 'assert': 0.29; 'produces': 0.29; 'code:': 0.29; 'skip:( 20': 0.30; 'handling': 0.30; 'header:Received:8': 0.31; 'skip:_ 10': 0.31; 'received:169': 0.32; 'could': 0.33; 'skip:- 10': 0.34; 'to:addr:python-list': 0.35; 'problem': 0.35; 'except': 0.35; 'charset:us-ascii': 0.36; 'subject:': 0.37; 'subject:: ': 0.37; 'email addr:python.org': 0.38; 'sent:': 0.38; 'sure': 0.38; 'received:10': 0.38; 'end': 0.38; 'to:addr:python.org': 0.39; 'from:': 0.39; 're:': 0.60; 'email name:python-list': 0.63; 'finally': 0.67; '.....': 0.76; '3...': 0.84; 'bare': 0.84; 'adopt': 0.91
X-Forefront-Antispam-Report CIP:59.163.77.45; KIP:(null); UIP:(null); IPV:NLI; H:KCHJEXHC01.kpit.com; RD:59.163.77.45.static.vsnl.net.in; EFVD:NLI
X-SpamScore -6
X-BigFish VPS-6(z2b68kzbb2dI98dI9371I542M1432Izz1202hzz8275dhz2dh2a8h668h839h944hd25hf0ah)
From Shambhu Rajak <Shambhu.Rajak@kpitcummins.com>
To "python-list@python.org" <python-list@python.org>
Subject RE: exception problem
Thread-Topic exception problem
Thread-Index AQHNUluk/3dEQuMIIUyW8ZdlsT250JcKfdCw
Date Mon, 25 Jun 2012 05:19:17 +0000
References <4FE79433.8020704@earthlink.net> <4FE7982C.5020708@mrabarnett.plus.com>
In-Reply-To <4FE7982C.5020708@mrabarnett.plus.com>
Accept-Language en-US
Content-Language en-US
X-MS-Has-Attach
X-MS-TNEF-Correlator
x-originating-ip [10.10.69.41]
Content-Type text/plain; charset="us-ascii"
Content-Transfer-Encoding quoted-printable
MIME-Version 1.0
X-OriginatorOrg kpitcummins.com
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1476.1340603387.4697.python-list@python.org> (permalink)
Lines 54
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1340603387 news.xs4all.nl 6948 [2001:888:2000:d::a6]:54016
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:24415

Show key headers only | View raw


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 comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

RE: exception problem Shambhu Rajak <Shambhu.Rajak@kpitcummins.com> - 2012-06-25 05:19 +0000

csiph-web