s = sha1(random()).hexdigest()

gert gert.cuykens at gmail.com
Fri Jan 16 19:54:40 EST 2009


On Jan 17, 1:14 am, gert <gert.cuyk... at gmail.com> wrote:
> On Jan 16, 7:08 am, "Martin v. Löwis" <mar... at v.loewis.de> wrote:
>
> > >  s = urandom(10).encode('hex')
>
> > >  AttributeError: 'bytes' object has no attribute 'encode'
>
> > py> binascii.hexlify(os.urandom(10))
> > b'92b91d5734a9fe562f23'
>
> sqlite3
>
>  s = hexlify(urandom(10))
>  db.execute('SELECT sid FROM sessions WHERE sid=?',(s))
>
> ('SELECT sid FROM sessions WHERE sid=?', b'c916f03d441a0b2b5a9d')
> [error] Incorrect number of bindings supplied. The current statement
> uses 1, and there are 20 supplied.
>
> ???

db.execute('SELECT sid FROM sessions WHERE sid=?',(s,))
This works ?

Is this the new way to create a list in Python3.0 ?
s=('test',)



More information about the Python-list mailing list