Re: [Python-Dev] Explicitly declaring expected exceptions for a block

2005-06-22 Thread Nick Coghlan
Dmitry Dvoinikov wrote: > Now, back to original question then, do you think it'd be > beneficial to have some sort of exception ignoring or expecting > statement ? Not really - as I said earlier, I usually have something non-trivial in the except or else clause, so I'm not simply ignoring the exc

Re: [Python-Dev] Explicitly declaring expected exceptions for a block

2005-06-21 Thread Dmitry Dvoinikov
> It was possible in PEP 340 and in early drafts of PEP 346, but it > isn't possible in PEP 343. > In PEP 343, the statement template *cannot* suppress exceptions - it > can react to them, and it can turn them into different exceptions, but > that's all. ...doing homework... The following code,

Re: [Python-Dev] Explicitly declaring expected exceptions for a block

2005-06-21 Thread Nick Coghlan
Paul Du Bois wrote: > If I understand PEP 343 correctly, it allows for easy implementation > of part of your request. It doesn't implement the else: clause, but > you don't give a use case for it either. > > class ignored_exceptions(object): >def __init__(self, *exceptions): >self.exce

Re: [Python-Dev] Explicitly declaring expected exceptions for a block

2005-06-20 Thread Dmitry Dvoinikov
> If you're trying to write tests, perhaps a better use-case would be > something like: > with required_exception(SomeError): > do something that should cause SomeError Yes, you are right, that'd be a better and more flexible way, thank you. Sincerely, Dmitry Dvoinikov http://www.targeted.or

Re: [Python-Dev] Explicitly declaring expected exceptions for a block

2005-06-20 Thread Paul Du Bois
On 6/20/05, Dmitry Dvoinikov <[EMAIL PROTECTED]> wrote: > Excuse me if I couldn't find that in the existing PEPs, but > wouldn't that be useful to have a construct that explicitly > tells that we know an exception of specific type could happen > within a block, like: > ignore TypeError: > do s

[Python-Dev] Explicitly declaring expected exceptions for a block

2005-06-20 Thread Dmitry Dvoinikov
Excuse me if I couldn't find that in the existing PEPs, but wouldn't that be useful to have a construct that explicitly tells that we know an exception of specific type could happen within a block, like: -- ignore TypeError: do stuff [else: do other stuff]