Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.066 X-Spam-Evidence: '*H*': 0.87; '*S*': 0.00; 'attribute': 0.07; 'exception,': 0.09; "(i'm": 0.16; 'colon.': 0.16; 'received:74.208.4.195': 0.16; 'subject:python3': 0.16; 'tried:': 0.16; '\xe9crit': 0.16; 'exception': 0.16; 'wrote:': 0.18; 'header :User-Agent:1': 0.23; 'header:In-Reply-To:1': 0.27; 'subject:) ': 0.29; 'related': 0.29; 'subject:list': 0.30; "skip:' 10": 0.31; 'exceptions': 0.31; 'url:python': 0.33; 'except': 0.35; 'but': 0.35; 'there': 0.35; 'thanks': 0.36; 'hi,': 0.36; 'url:org': 0.36; 'searching': 0.37; 'e.g.': 0.38; 'url:library': 0.38; 'to:addr :python-list': 0.38; 'pm,': 0.38; 'does': 0.39; 'bad': 0.39; 'to:addr:python.org': 0.39; 'skip:z 20': 0.60; 'hope': 0.61; 'mentioned': 0.61; 'url:3': 0.61; 'course': 0.61; 'such': 0.63; 'received:74.208': 0.68; 'feedback,': 0.84 Date: Mon, 24 Jun 2013 22:09:12 -0400 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6 MIME-Version: 1.0 To: python-list@python.org Subject: Re: (newbye) exceptions list for python3 classes References: <51c8bb87$0$2407$426a74cc@news.free.fr> <51c8bd9d$0$18756$426a34cc@news.free.fr> In-Reply-To: <51c8bd9d$0$18756$426a34cc@news.free.fr> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Provags-ID: V02:K0:FXW74w4Pt0sezdXrnja8nvgXNKI2XpPueeIQWR9fvDk IhSZkjOSURdPnvEOG6suoHSbGhPaRfNTDx0ZnaIxVEuQFW/h+M GAvn1CxMbzZam3yw/oE5CkiM6fK4Xrgqw6zPOCfob6BZfnDcAh P9Xq2FmkAh5px2v33d5HGFeYTpMDzzI9t7mlK/3/aYC2tH8alj GuPw1Nf2nMjBLI3kVQPUP/SZFxI8Mo2QRetsoVZO9LZjuicO8W xtM7LSvAgcsTi301hwFD5xDzJpMmcMW6Gzu2Tg/nDniKBt39y3 2yv3CvQ/fEXSTdIFGXu/nNax+zdYkWkic8gdgIs+0Ej4pMGyli gHt/bHFMTJWBGI5C+UQ0= X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 39 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1372126168 news.xs4all.nl 15932 [2001:888:2000:d::a6]:36318 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:49118 On 06/24/2013 05:43 PM, chrem wrote: > Le 24/06/13 23:35, chrem a écrit : >> Hi, >> >> what is the best way to find out all exceptions for a class? >> E.g. I want to find out all exceptions related to the zipfile (I'm >> searching for the Bad password exception syntax). >> >> thanks for your help or feedback, >> Christophe > > without exception, it shown: > RuntimeError: ('Bad password for file', 0x100756690>) > > then I tried: > except zipfile.BadPassword: You cannot just make up a name, and hope that it's a valid exception type. There is no such exception as zipfile.BadPassword. There is an exception, zipfile.BadZipFile, as mentioned at http://docs.python.org/3.3/library/zipfile.html#zipfile.BadZipFile But of course that's not what you want. The exception type above is RuntimeError, the part before the colon. > print("Password does not match") > but it returned: > AttributeError: 'module' object has no attribute 'BadPassword' > > > > -- DaveA