how to insert random error in a programming

Mark Lawrence breamoreboy at yahoo.co.uk
Mon Oct 15 15:28:46 EDT 2012


On 15/10/2012 20:10, Joshua Landau wrote:
> On 15 October 2012 14:55, Debashish Saha <silideba at gmail.com> wrote:
>
>> how to insert random error in a programming?
>>
>
> You could always just *write* the code with random errors from the start.
> Try random code, like this:
>
> from collections import defaultdict as ð
>> def ire(ł, æ=[]):
>> yield [ð(bool, {æ and æ[0]or object(): True}) [ł[0]] or [lambda: (yield
>> ire(((æ.append(object()), æ[0])[0], ł))), int][(ł>ł[:3])|(ł<=ł[:2])]() or
>> [1]][0]
>> print(list(list(ire([2, 3, 3]))[0]))
>
>
> Note that being random code this does nothing other than confuse people as
> to why it does what it does do even though that is nothing other than the
> mentioned confusion of others into its purpose.
>
>
>

I like clearly written code like this

"
s = """Gur Mra bs Clguba, ol Gvz Crgref

Ornhgvshy vf orggre guna htyl.
Rkcyvpvg vf orggre guna vzcyvpvg.
Fvzcyr vf orggre guna pbzcyrk.
Pbzcyrk vf orggre guna pbzcyvpngrq.
Syng vf orggre guna arfgrq.
Fcnefr vf orggre guna qrafr.
Ernqnovyvgl pbhagf.
Fcrpvny pnfrf nera'g fcrpvny rabhtu gb oernx gur ehyrf.
Nygubhtu cenpgvpnyvgl orngf chevgl.
Reebef fubhyq arire cnff fvyragyl.
Hayrff rkcyvpvgyl fvyraprq.
Va gur snpr bs nzovthvgl, ershfr gur grzcgngvba gb thrff.
Gurer fubhyq or bar-- naq cersrenoyl bayl bar --boivbhf jnl gb qb vg.
Nygubhtu gung jnl znl abg or boivbhf ng svefg hayrff lbh'er Qhgpu.
Abj vf orggre guna arire.
Nygubhtu arire vf bsgra orggre guna *evtug* abj.
Vs gur vzcyrzragngvba vf uneq gb rkcynva, vg'f n onq vqrn.
Vs gur vzcyrzragngvba vf rnfl gb rkcynva, vg znl or n tbbq vqrn.
Anzrfcnprf ner bar ubaxvat terng vqrn -- yrg'f qb zber bs gubfr!"""

d = {}
for c in (65, 97):
     for i in range(26):
         d[chr(i+c)] = chr((i+13) % 26 + c)

print "".join([d.get(c, c) for c in s])
"

-- 
Cheers.

Mark Lawrence.




More information about the Python-list mailing list