random # errors?

Aahz Maruch aahz at netcom.com
Fri Jun 16 16:02:53 EDT 2000


In article <8h8h2g$nia$1 at nnrp1.deja.com>, Arinté  <jamarijr at my-deja.com> wrote:
>
>Here is the calling code.
>
>def biko(w,h):
>        len = w * h
>        bytes = len/8
>        cvt=0
>        ret = ""
>        gen = whrandom.whrandom()
>        for idx in range(bytes):
>                cvt = gen.randint(0,255)
>                ret = ret +chr(cvt)
>        return ret

First of all, if len>8000 at all frequently, the "ret=ret+chr()" call is
going to get somewhat costly, because you copy/create a new string each
time.

Secondly, I still can't figure out what the problem is, partly because I
don't know whether it's dying on the call to whrandom.whrandom() or the
call to gen.randint().

Side note: you should not use whrandom, you should use random.
--
                      --- Aahz (Copyright 2000 by aahz at netcom.com)

Androgynous poly kinky vanilla queer het    <*>     http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6

"The only problem with Microsoft is they just have no taste." --Steve Jobs
(From _Triumph of the Nerds_ PBS special)



More information about the Python-list mailing list