[Tutor] How to run this block of code dozens of times
etanes.rm at gmail.com
Mon Sep 17 02:56:20 CEST 2012
On Sun, Sep 16, 2012 at 5:23 PM, Dave Angel <d at davea.name> wrote:
> On 09/16/2012 07:56 PM, Scurvy Scott wrote:
> > scratch that, new code is below for your perusal:
> > from Crypto.PublicKey import RSA
> > import hashlib
> > def repeat_a_lot():
> > count = 0
> > while count < 20:
> >You're kidding, aren't you? while loops are meant for those times when
> >you don't know how many times the loop is to iterate.
Acutally, Dave, I would be the one setting just how many times the loop
would run manually. Actually the loop would run 2^80 times, so it was more
of a test to see if the output was different each time it ran more than
trying to run it the correct amount of times.
> > m = RSA.generate(1024)
> > b = hashlib.sha1()
> > b.update(str(m))
> > a = b.hexdigest()
> > print a[:16] + '.onion'
> > count += 1
> > repeat_a_lot()
> def repeat_a_lot():
> for _ in xrange(20):
> m = RSA.generate(1024)
> b = hashlib.sha1()
> a = b.hexdigest()
> print a[:16] + '.onion'
Why would you use an underscore rather than a letter or name like I've
always seen. I've never seen an underscore used before.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor