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


Groups > comp.lang.python > #49118

Re: (newbye) exceptions list for python3 classes

Date 2013-06-24 22:09 -0400
From Dave Angel <davea@davea.name>
Subject Re: (newbye) exceptions list for python3 classes
References <51c8bb87$0$2407$426a74cc@news.free.fr> <51c8bd9d$0$18756$426a34cc@news.free.fr>
Newsgroups comp.lang.python
Message-ID <mailman.3792.1372126168.3114.python-list@python.org> (permalink)

Show all headers | View raw


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', <zipfile.ZipInfo object at
> 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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

(newbye) exceptions list for python3 classes chrem <usenetNoSpam@chr1st0ph9.eu> - 2013-06-24 23:35 +0200
  Re: (newbye) exceptions list for python3 classes chrem <usenetNoSpam@chr1st0ph9.eu> - 2013-06-24 23:43 +0200
    Re: (newbye) exceptions list for python3 classes alex23 <wuwei23@gmail.com> - 2013-06-25 09:22 +1000
    Re: (newbye) exceptions list for python3 classes Dave Angel <davea@davea.name> - 2013-06-24 22:09 -0400
    Re: (newbye) exceptions list for python3 classes chrem <usenetNoSpam@chr1st0ph9.eu> - 2013-06-25 17:55 +0200
  Re: (newbye) exceptions list for python3 classes Ben Finney <ben+python@benfinney.id.au> - 2013-06-25 09:27 +1000

csiph-web