Path: csiph.com!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Paul Rubin Newsgroups: comp.lang.python Subject: Re: raise None Date: Wed, 30 Dec 2015 16:19:54 -0800 Organization: A noiseless patient Spider Lines: 10 Message-ID: <87d1tnxydx.fsf@jester.gateway.pace.com> References: <56847239$0$1590$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="7fb8b9b5119ed656382b2cea88166c4f"; logging-data="23203"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19A5QrWzAfPeIz2RT1ctEQ8" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:Obqyik18LKHAMRrI/Mv/FoQe5MI= sha1:TrlPEWnNrGY5dy3CgbZZhixFhUc= Xref: csiph.com comp.lang.python:101028 Steven D'Aprano writes: > def _validate(a, b): > if condition(a) or condition(b): return TypeError > ... > Obviously this doesn't work now, since raise None is an error, but if it did > work, what do you think? Never occurred to me. But in some analogous situations I've caught the exception inside _validate, then peeled away some layers of the traceback from the exception output before throwing again.