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

References <CA+b=61AiVYehyGbFyvyTqsfZeio1NoWKtw1SwJV_r_MZ1BcVwA@mail.gmail.com> <CAPTjJmpK1edyzOdORPyv8M_WCzgqzcJwRJG2pTb2j-d85ANEUA@mail.gmail.com> <k5hggg$cru$2@ger.gmane.org>
Date 2012-10-16 06:05 +1100
Subject Re: how to insert random error in a programming
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.2230.1350327916.27098.python-list@python.org> (permalink)

Show all headers | 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