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


Groups > comp.lang.python > #31334

Re: how to insert random error in a programming

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
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; 'ah,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'happily': 0.16; 'inserting': 0.16; 'nameerror': 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; '>>>': 0.18; '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; 'errors.': 0.27; 'message-id:@mail.gmail.com': 0.27; 'chris': 0.28; 'error': 0.30; 'certain': 0.33; 'to:addr :python-list': 0.33; 'point.': 0.33; 'version': 0.34; 'received:google.com': 0.34; 'programming.': 0.35; 'received:209.85': 0.35; 'something': 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; 'think': 0.40; 'worth': 0.63; 'potentially': 0.66; 'yours': 0.88
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=2lZFsFfolg1cZQnHSVEQxc1kFypUPf5AeSD9i/8eKAM=; b=C3C7CPARetuKzedGQfz7oF7ovcwoWOlAC0awbylPi2Ks51qFHVBDVKmhjqABKdlTG8 hta46qOtd7p+XHjA7TahlKyM0gByotaMv0FWU/tDeldWaVzGg+ibz2LWz3BXPNW4bsNE xp1CBUN8f5xwVnkkr6ecZKTrjeJRo4dF0vATM9gVXTVwdCpQFv/ei2HcWjWbotwawIsf 2kA4QHaiOLCDnrDXH2ZYIiQNBbJ0ddPrSPy8LfG80qGS3EBsZTXpyuR1TVnVW/yTC+GV j8xst/wr40ni9jBcuUd/zOPtXBCS1kvNxBIgJ/7W6clFE11ZMY5Q8iO/Mx50Ww4JTS3a q02g==
MIME-Version 1.0
In-Reply-To <k5hggg$cru$2@ger.gmane.org>
References <CA+b=61AiVYehyGbFyvyTqsfZeio1NoWKtw1SwJV_r_MZ1BcVwA@mail.gmail.com> <CAPTjJmpK1edyzOdORPyv8M_WCzgqzcJwRJG2pTb2j-d85ANEUA@mail.gmail.com> <k5hggg$cru$2@ger.gmane.org>
Date Tue, 16 Oct 2012 06:05:13 +1100
Subject Re: how to insert random error in a programming
From Chris Angelico <rosuav@gmail.com>
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2230.1350327916.27098.python-list@python.org> (permalink)
Lines 23
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1350327916 news.xs4all.nl 6868 [2001:888:2000:d::a6]:39715
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:31334

Show key headers only | View raw


On Tue, Oct 16, 2012 at 4:18 AM, Serhiy Storchaka <storchaka@gmail.com> wrote:
> On 15.10.12 17:04, Chris Angelico wrote:
>> On Tue, Oct 16, 2012 at 12:55 AM, Debashish Saha <silideba@gmail.com> 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))()
>
> I think OP means something like
>
> programming[:0] = random.choice((OSError,IOError,ZeroDivisionError,UnicodeDecodeError,AssertionError))()

Ah, good point. Though it's worth noting that my version will happily
raise a NameError under certain circumstances, while yours will never
insert a NameError into programming.

This is potentially very important when inserting random errors.

ChrisA

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


Thread

Re: how to insert random error in a programming Chris Angelico <rosuav@gmail.com> - 2012-10-16 06:05 +1100

csiph-web