Re: py3k: converting int to bytes

2011-02-26 Thread J. Gerlach
Am 24.02.2011 17:19, schrieb s...@uce.gov: Is there a better way to convert int to bytes then going through strings: x=5 str(x).encode() Thanks. bytes([8]) b'\x08' seems more straight forward... -- http://mail.python.org/mailman/listinfo/python-list

Re: py3k: converting int to bytes

2011-02-26 Thread J. Gerlach
Am 26.02.2011 12:26, schrieb J. Gerlach: Am 24.02.2011 17:19, schrieb s...@uce.gov: Is there a better way to convert int to bytes then going through strings: x=5 str(x).encode() Thanks. bytes([8]) b'\x08' seems more straight forward... ... but it gives a different result. I

Re: ImportError: No module named gobject

2011-02-22 Thread J. Gerlach
Am 21.02.2011 16:04, schrieb Luther: I've tried installing pygtk, pygobject, and gobject-introspection from source, but none of them will compile, and nothing I install through synaptic has any effect. I've tried too many things to post all the details here, but I'll post any details on

Re: group 0 in the re module

2010-12-08 Thread J. Gerlach
Am 08.12.2010 03:23, schrieb Yingjie Lan: Hi, According to the doc, group(0) is the entire match. m = re.match(r(\w+) (\w+), Isaac Newton, physicist) m.group(0) # The entire match 'Isaac Newton' But if you do this: import re re.sub(r'(\d{3})(\d{3})', r'\0 to \1-\2', '757234')

Re: hashlib in one line

2010-11-29 Thread J. Gerlach
Am 29.11.2010 14:50, schrieb Thomas Guettler: Hi, I think it would be nice if you could use the hashlib in one line: hashlib.sha256().update('abc').hexdigest() Unfortunately update() returns None. Is there a way to convert a string to the hexdigest of sha256 in one line? Thomas

Re: Why flat is better than nested?

2010-11-06 Thread J. Gerlach
Am 06.11.2010 02:36, schrieb Steven D'Aprano: On Fri, 05 Nov 2010 14:19:47 +0100, J. Gerlach wrote: Am 28.10.2010 03:40, schrieb Steven D'Aprano: [ snip a lot of wise words ] Can I put this (translated) in the german python wiki? I guess it might help more people to understand some

Re: Why flat is better than nested?

2010-11-05 Thread J. Gerlach
Am 28.10.2010 03:40, schrieb Steven D'Aprano: [ snip a lot of wise words ] Can I put this (translated) in the german python wiki? I guess it might help more people to understand some decisions taken during python's development - and I'm to lazy to do something similar myself ;) Greetings from

Re: PEP 249 (database api) -- executemany() with iterable?

2010-10-13 Thread J. Gerlach
Am 13.10.2010 14:26, schrieb Jon Clements: On 12 Oct, 20:21, J. Gerlach gerlach_jo...@web.de wrote: Am 12.10.2010 17:10, schrieb Roy Smith: [A]re there any plans to update the api to allow an iterable instead of a sequence? [sqlite3 example snipped] What happens if you do

Re: PEP 249 (database api) -- executemany() with iterable?

2010-10-12 Thread J. Gerlach
Am 12.10.2010 17:10, schrieb Roy Smith: [A]re there any plans to update the api to allow an iterable instead of a sequence? sqlite3 (standard library, python 2.6.6., Windows 32Bit) does that already:: import sqlite3 as sql connection = sql.connect(:memory:) cursor = connection.execute(