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
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
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
Changes by Qiangning Hong hon...@gmail.com:
--
nosy: +hongqn
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14562
___
___
Python-bugs-list mailing
Changes by Qiangning Hong hon...@gmail.com:
--
nosy: +hongqn
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9205
___
___
Python-bugs-list mailing
Changes by Qiangning Hong hon...@gmail.com:
--
nosy: +hongqn
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue4947
___
___
Python-bugs-list mailing
Changes by Qiangning Hong hon...@gmail.com:
--
nosy: +hongqn
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1722344
___
___
Python-bugs-list
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
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
Changes by Qiangning Hong [EMAIL PROTECTED]:
--
nosy: +hongqn
___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2277
___
___
Python-bugs-list mailing list
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
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
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],
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 (.
--
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
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*
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
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. :)
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
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,
;')
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
(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
%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
'
(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
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
):
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
, 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
?
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
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
...
--
Qiangning Hong
__
( Michael:)
( )
( Hi. I'm Michael Jackson, from The Jacksons. )
( )
( Homer: I'm Homer Simpson
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
. 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
. And for on_received(), there may be up
to 16 threads accessing it simultaneously.
--
Qiangning Hong
___
/ BOFH Excuse #208: \
| |
| Your mail is being routed
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
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
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
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
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
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',
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
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
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
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
43 matches
Mail list logo