[issue19224] Make hash(None) consistent among processes

2013-10-10 Thread Qiangning Hong
Changes by Qiangning Hong hon...@gmail.com: -- keywords: +patch Added file: http://bugs.python.org/file32043/hash_of_none.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19224

[issue19224] Make hash(None) consistent among processes

2013-10-10 Thread Qiangning Hong
New submission from Qiangning Hong: Integers, strings, and bool's hash are all consistent for processes of a same interpreter. However, hash(None) differs. $ python -c print(hash(None)) 272931276 $ python -c print(hash(None)) 277161420 It's wired and make difficulty for distributed systems

[issue19224] Make hash(None) consistent among processes

2013-10-10 Thread Qiangning Hong
Qiangning Hong added the comment: Return 1315925605 now :) -- Added file: http://bugs.python.org/file32044/hash_of_none.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19224

[issue14562] urllib2 maybe blocks too long with small chunks

2012-04-16 Thread Qiangning Hong
Changes by Qiangning Hong hon...@gmail.com: -- nosy: +hongqn ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14562 ___ ___ Python-bugs-list mailing

[issue9205] Parent process hanging in multiprocessing if children terminate unexpectedly

2011-03-08 Thread Qiangning Hong
Changes by Qiangning Hong hon...@gmail.com: -- nosy: +hongqn ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9205 ___ ___ Python-bugs-list mailing

[issue4947] sys.stdout fails to use default encoding as advertised

2009-02-04 Thread Qiangning Hong
Changes by Qiangning Hong hon...@gmail.com: -- nosy: +hongqn ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4947 ___ ___ Python-bugs-list mailing

[issue1722344] Thread shutdown exception in Thread.notify()

2009-01-26 Thread Qiangning Hong
Changes by Qiangning Hong hon...@gmail.com: -- nosy: +hongqn ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1722344 ___ ___ Python-bugs-list

Re: sys.stdout.write()'s bug or doc bug?

2008-12-28 Thread Qiangning Hong
On Dec 27, 12:31 am, Martin mar...@marcher.name wrote: Python 2.4.4 (#2, Oct 22 2008, 19:52:44) [GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2 Type help, copyright, credits or license for more information. u = u\u554a print u 啊 sys.stdout.write(u + \n) Traceback (most

sys.stdout.write()'s bug or doc bug?

2008-12-25 Thread Qiangning Hong
u = u'\u554a' print u 啊 sys.stdout.write(u) Traceback (most recent call last): File stdin, line 1, in module UnicodeEncodeError: 'ascii' codec can't encode character u'\u554a' in position 0: ordinal not in range(128) type(sys.stdout) type 'file' sys.stdout.encoding 'UTF-8' Quote from file

[issue2277] MozillaCookieJar does not support Firefox3 cookie files

2008-06-20 Thread Qiangning Hong
Changes by Qiangning Hong [EMAIL PROTECTED]: -- nosy: +hongqn ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue2277 ___ ___ Python-bugs-list mailing list

Re: Prevent self being passed to a function stored as a member variable?

2006-09-04 Thread Qiangning Hong
On 4 Sep 2006 09:39:32 -0700, Sandra-24 [EMAIL PROTECTED] wrote: How can you prevent self from being passed to a function stored as a member variable? class Foo(object): def __init__(self, callback): self.func = callback f =Foo(lambda x: x) f.func(1) # TypeError, func expects 1

Re: Is this a good idea or a waste of time?

2006-08-24 Thread Qiangning Hong
On 24 Aug 2006 20:53:49 -0700, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: That's bad form. If you insist on doing something like this, at least use isinstance(a, str) instead of typeof. But even that breaks duck typing; if a is a unicode string, that'll fail when the function may work fine

splitting words with brackets

2006-07-26 Thread Qiangning Hong
I've got some strings to split. They are main words, but some words are inside a pair of brackets and should be considered as one unit. I prefer to use re.split, but haven't written a working one after hours of work. Example: a (b c) d [e f g] h i should be splitted to [a, (b c), d, [e f g],

Re: splitting words with brackets

2006-07-26 Thread Qiangning Hong
faulkner wrote: re.findall('\([^\)]*\)|\[[^\]]*|\S+', s) sorry i forgot to give a limitation: if a letter is next to a bracket, they should be considered as one word. i.e.: a(b c) d becomes [a(b c), d] because there is no blank between a and (. --

Re: splitting words with brackets

2006-07-26 Thread Qiangning Hong
Tim Chase wrote: import re s ='a (b c) d [e f g] h ia abcd(b c)xyz d [e f g] h i' r = re.compile(r'(?:\S*(?:\([^\)]*\)|\[[^\]]*\])\S*)|\S+') r.findall(s) ['a', '(b c)', 'd', '[e f g]', 'h', 'ia', 'abcd(b c)xyz', 'd', '[e f g]', 'h', 'i'] [...] However, the above monstrosity passes

Re: splitting words with brackets

2006-07-26 Thread Qiangning Hong
Simon Forman wrote: def splitup(s): return re.findall(''' \S*\( [^\)]* \)\S* | \S*\[ [^\]]* \]\S* | \S+ ''', s, re.VERBOSE) Yours is the same as Tim's, it can't handle a word with two or more brackets pairs, too. I tried to change the \S*\([^\)]*\)\S*

Re: splitting words with brackets

2006-07-26 Thread Qiangning Hong
Simon Forman wrote: What are the desired results in cases like this: (a b)[c d] or (a b)(c d) ? [(a b)[c d]], [(a b)(c d)] -- http://mail.python.org/mailman/listinfo/python-list

Re: splitting words with brackets

2006-07-26 Thread Qiangning Hong
Tim Chase wrote: Ah...the picture is becoming a little more clear: r = re.compile(r'(?:\([^\)]*\)|\[[^\]]*\]|\S)+') r.findall(s) ['(a c)b(c d)', 'e'] It also works on my original test data, and is a cleaner regexp than the original. The clearer the problem, the clearer the answer. :)

Re: hash() yields different results for different platforms

2006-07-12 Thread Qiangning Hong
Grant Edwards wrote: On 2006-07-11, Qiangning Hong [EMAIL PROTECTED] wrote: However, when I come to Python's builtin hash() function, I found it produces different values in my two computers! In a pentium4, hash('a') - -468864544; in a amd64, hash('a') - 12416037344. Does hash function

hash() yields different results for different platforms

2006-07-11 Thread Qiangning Hong
I'm writing a spider. I have millions of urls in a table (mysql) to check if a url has already been fetched. To check fast, I am considering to add a hash column in the table, make it a unique key, and use the following sql statement: insert ignore into urls (url, hash) values (newurl,

Re: need help with my append syntax

2005-08-12 Thread Qiangning Hong
;') Is addr is really a string? AFAIK, strings havn't an append methond. use += to extend strings: . addr = 'abc' . addr += '%s;' . addr 'abc%s;' -- Qiangning Hong I'm usually annoyed by IDEs because, for instance, they don't use VIM as an editor. Since I'm hooked to that, all IDEs I've used so

what's wrong with my code using subprocess?

2005-07-23 Thread Qiangning Hong
(data) count += 1 if count = 1000: print p.stdin, 'exit' print 'waiting subprocess exit' p.wait() if __name__ == '__main__': main() -- Qiangning Hong I'm usually annoyed by IDEs because, for instance, they don't use VIM as an editor. Since

Re: tuple to string?

2005-07-22 Thread Qiangning Hong
%c%c%c' % t 'spam' (use struct model): . import struct . struct.pack('', *t) 'spam' -- Qiangning Hong I'm usually annoyed by IDEs because, for instance, they don't use VIM as an editor. Since I'm hooked to that, all IDEs I've used so far have failed to impress me. -- Sybren Stuvel

Re: tuple to string?

2005-07-22 Thread Qiangning Hong
' (use struct model): . import struct . struct.pack('', *t) 'spam' -- Qiangning Hong I'm usually annoyed by IDEs because, for instance, they don't use VIM as an editor. Since I'm hooked to that, all IDEs I've used so far have failed to impress me. -- Sybren Stuvel @ c.l.python Get Firefox

Re: PyArg_ParseTuple help

2005-07-10 Thread Qiangning Hong
a python string to replace ``in'' and ``inlen''. Then, the prototype of the function is something like: def func(ins, v) which returns a string. [...] -- Qiangning Hong -- http://mail.python.org/mailman/listinfo/python-list

Re: Create datetime instance using a tuple.

2005-07-06 Thread Qiangning Hong
): File stdin, line 1, in ? TypeError: function takes at least 3 arguments (1 given) (class datetime(year, month, day[, hour[, minute[, second[, microsecond[, tzinfo]) Use: dt = datetime(*t) -- Qiangning Hong Get Firefox! http://www.spreadfirefox.com/?q=affiliatesamp;id=67907amp;t=1

Re: frozenset question

2005-07-06 Thread Qiangning Hong
, in ? TypeError: set objects are unhashable . {s2:1} {frozenset([2]): 1} -- Qiangning Hong Get Firefox! http://www.spreadfirefox.com/?q=affiliatesamp;id=67907amp;t=1 -- http://mail.python.org/mailman/listinfo/python-list

debugger?

2005-07-03 Thread Qiangning Hong
? Or what more polish feature you want to see in an ideal python debugger? -- hope this thread will help IDE developers to fill their todo list with some shining ideas :) -- Qiangning Hong Get Firefox! http://www.spreadfirefox.com/?q=affiliatesamp;id=67907amp;t=1 -- http://mail.python.org/mailman

Re: debugger?

2005-07-03 Thread Qiangning Hong
Detlev Offenbach wrote: Qiangning Hong wrote: I have read a lot of posts discussing python IDEs, but most of them focus on the editor, GUI builder, project management, customizability, etc Some talked about debugging capability, but only on an available/unavailable level. I use vim

how to shrink a numarray array?

2005-06-29 Thread Qiangning Hong
... -- Qiangning Hong __ ( Michael:) ( ) ( Hi. I'm Michael Jackson, from The Jacksons. ) ( ) ( Homer: I'm Homer Simpson

Re: Can we pass some arguments to system(cmdline)?

2005-06-20 Thread Qiangning Hong
dir) would cause python to execute ls dir where dir might not exist at all! Is there a way to reproduce the same thing in Python? Thanks for any insights. cheers, Didier. You should use something like this: dir = /home/cypher system(ls %s % dir) -- Qiangning Hong

collect data using threads

2005-06-14 Thread Qiangning Hong
. Will it cause data lose if there is a thread is appending data to self.data at the same time? Is there a more pythonic/standard recipe to collect thread data? -- Qiangning Hong ___ Those who can, do; those who can't, simulate

Re: collect data using threads

2005-06-14 Thread Qiangning Hong
. And for on_received(), there may be up to 16 threads accessing it simultaneously. -- Qiangning Hong ___ / BOFH Excuse #208: \ | | | Your mail is being routed

Re: Show current ip on Linux

2005-06-13 Thread Qiangning Hong
on a linux. i Have rwite some piece of code that realy work under Windows XP, but the same script wil not work on Linux. Verry thanks to all vulunteers. How about use the shell command ifconfig | grep inet ? -- Qiangning Hong

Re: compare two voices

2005-05-01 Thread Qiangning Hong
Jeremy Bowers wrote: No matter how you slice it, this is not a Python problem, this is an intense voice recognition algorithm problem that would make a good PhD thesis. No, my goal is nothing relative to voice recognition. Sorry that I haven't described my question clearly. We are not

compare two voices

2005-04-30 Thread Qiangning Hong
I want to make an app to help students study foreign language. I want the following function in it: The student reads a piece of text to the microphone. The software records it and compares it to the wave-file pre-recorded by the teacher, and gives out a score to indicate the similarity between

distutils question: different projects under same namespace

2005-04-16 Thread Qiangning Hong
To avoid namespace confliction with other Python packages, I want all my projects to be put into a specific namespace, e.g. 'hongqn' package, so that I can use from hongqn.proj1 import module1, from hongqn.proj2.subpack1 import module2, etc. These projects are developed and maintained and

distutils question: different projects under same namespace

2005-04-15 Thread Qiangning Hong
To avoid namespace confliction with other Python packages, I want all my projects to be put into a specific namespace, e.g. 'hongqn' package, so that I can use from hongqn.proj1 import module1, from hongqn.proj2.subpack1 import module2, etc. These projects are developed and maintained and

distutils: package data

2005-03-29 Thread Qiangning Hong
I am writing a setup.py for my package. I have a pre-compiled myextmod.pyd file in my package and I want the distutils to automatically copy it to C:\Python23\Lib\site-packages\mypackage\myextmod.pyd. I try to add the following parameter to setup(): data_file = [('mypackage',

unittest help

2005-03-24 Thread Qiangning Hong
I want to apply TDD (test driven development) on my project. I am working on a class like this (in plan): # file: myclass.py import _extmod class MyClass(object): def __init__(self): self.handle = _extmod.open() def __del__(self): _extmod.close(self.handle) def

how to absolute import?

2005-03-10 Thread Qiangning Hong
From Guido's PEP8: - Relative imports for intra-package imports are highly discouraged. Always use the absolute package path for all imports. Does it mean I should put my develop directory into PYTHONPATH (e.g. /home/hongqn/devel/python) and use import myproj1.package1.module1

predict directory write permission under windows?

2004-12-13 Thread Qiangning Hong
I want to know if I can write files into a directory before I actually perferm the write behavor. I found os.access(path, os.W_OK) but it uses real uid/gid to check instead of euid/egid so it doesn't fit my problem. I don't know how to get euid/egid under windows so I cannot use the mode

notification for cd insertion

2004-12-04 Thread Qiangning Hong
I want one of my function to execute when a cdrom is inserted. How can I achieve that? Further more, I want to do different things depend on the inserted disc type: if it is a normal cd-rom, read from it; if it is a recordable cd, write data on it. So, how can I get the inserted disc type