Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; '16,': 0.03; 'url:faqs': 0.09; 'subject:error': 0.11; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'oct': 0.16; 'skip:r 80': 0.16; 'subject:programming': 0.16; 'subject:random': 0.16; 'url:catb': 0.16; 'url:~esr': 0.16; 'wrote:': 0.17; 'received:209.85.214.174': 0.21; 'insert': 0.23; 'raise': 0.24; 'random': 0.24; 'header:In- Reply-To:1': 0.25; 'am,': 0.27; 'question': 0.27; 'message- id:@mail.gmail.com': 0.27; 'error': 0.30; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'received:209.85': 0.35; 'but': 0.36; 'url:org': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'header:Received:5': 0.40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=xQcAvM395veM/gzFakaGicET39lzo+aDaPf5OKi4Q34=; b=mvGe92317oDEdkWfI3LJ7ecaTl9oXC0KEpkW7MP3raW+JuGS/Jbps5jyvZOngEiUel zYBK2Mdj+fTeezP39OatEdHd9kTDqeYCxc/eyvEkaQlN9ORTk0lLHVo5VoKp5eNPXNYu i86RsATAO1DPXPiJnDCeOENyKPyBHl2Uuzkn6AoRxBuuwjlmHhD0J0rmuv2CjNqdOwY/ d7kw/VftBLDiLMY0XIkaHMFrGCjh1xBwWZwvkX7XO9CMXoAtkT05hPe96M0J29fUME6/ CaOUirMdDik9e2CVjSmljT10oHVwUT14/jYLI3c+bNl9z+zhpgqdlPzUwmP6cRzjDNrb XNzw== MIME-Version: 1.0 In-Reply-To: References: Date: Tue, 16 Oct 2012 01:04:49 +1100 Subject: Re: how to insert random error in a programming From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 11 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1350309891 news.xs4all.nl 6951 [2001:888:2000:d::a6]:33462 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:31306 On Tue, Oct 16, 2012 at 12:55 AM, Debashish Saha wrote: > how to insert random error in a programming? how to ask question good in forumming? http://www.catb.org/~esr/faqs/smart-questions.html But here's one way to do it: raise random.choice((OSError,IOError,ZeroDivisionError,UnicodeDecodeError,AssertionError))() ChrisA