Why the result

2006-10-20 Thread HYRY
Why the third print stement output "'comments': [(1, 2, 3)]", I think it should be []. I am using Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on win32. # program class PicInfo: def __init__(self, intro="", tags="", comments=[]): self.picintro = intro s

make a simple search function for homepage

2006-10-30 Thread HYRY
I want to add some simple search function for my homepage. It need to search through all the html files of my homepage (about 300 pages), and highlight the search words. I made some test with HTMLParser, it works but slow. So, my question is how can I improve its speed? from HTMLParser import HTM

How to increase the speed of this program?

2006-11-27 Thread HYRY
I want to join two mono wave file to a stereo wave file by only using the default python module. Here is my program, but it is much slower than the C version, so how can I increase the speed? I think the problem is at line #1, #2, #3. import wave import array lfile = wave.open(lfilename) rfile = w

Re: How to increase the speed of this program?

2006-11-28 Thread HYRY
I think oarray = array.array("h", [0]*(len(larray)+len(rarray))) #1 oarray[0::2] = larray#2 oarray[1::2] = rarray#3 will be executed at C level, but if I use itertools, the program is executed at Python level. So the itertools

Re: How to increase the speed of this program?

2006-11-28 Thread HYRY
Peter Otten wrote: > HYRY wrote: > > > I want to join two mono wave file to a stereo wave file by only using > > the default python module. > > Here is my program, but it is much slower than the C version, so how > > can I increase the speed? > > I thi

Re: PEP 3131: Supporting Non-ASCII Identifiers

2007-05-15 Thread HYRY
> - should non-ASCII identifiers be supported? why? Yes. I want this for years. I am Chinese, and teaching some 12 years old children learning programming. The biggest problem is we cannot use Chinese words for the identifiers. As the program source becomes longer, they always lost their thought ab

Re: PEP 3131: Supporting Non-ASCII Identifiers

2007-05-15 Thread HYRY
> That is a good point, but I'd like to ask out of curiosity, at what age > do children generally learn pinyin? (Assuming you speak Mandarin. If > not, replace pinyin with the name of whatever phonetic transliteration > is common in your region.) Granted, pinyin shoehorned into ASCII loses > its t

Re: PEP 3131: Supporting Non-ASCII Identifiers

2007-05-15 Thread HYRY
> The other thing is trying to teach them formal operational logic when > they are not yet ready for it. In that case it would be better to wait > until they are ready, but unfortunately there are large variations in > the age at which children become ready. Please do not confuse the two > very dif

Re: PEP 3131: Supporting Non-ASCII Identifiers

2007-05-16 Thread HYRY
> How do you feel about the mix of English keywords and Chinese? > How does the English - like "sentences " look to a Chinese? > > Would you support the extension of this PEP to include Chinese > Keywords? > > Would that be a lesser or greater gift? > Because the students can remember some English

the address of list.append and list.append.__doc__

2007-09-25 Thread HYRY
I have the following questions, I am using Python 2.4.2 >>> a = [1,2,3] >>> id(a.append) 19167152 #1 >>> id(list.append) 11306608 #1 1. the address of a.append and list.append is different, can I get the address of list.append from a.append? >>> id(a.append.__doc__) 19162720

Re: the address of list.append and list.append.__doc__

2007-09-25 Thread HYRY
> No. a.append is a "bound method" - a method that already has an > associated instance, that will be provided as the first argument to the > method call. Bound methods are created "on the fly". > Does this means there is no method to get the original methods from the Bound methods created "on the

Re: the address of list.append and list.append.__doc__

2007-09-25 Thread HYRY
> "the problem"? > Perhaps if you explain what you really want to do, someone can think the > way to do that, most likely *not* using id() Thanks, now I know I cannot use id() for my problem. Here is my problem: I want to add a docstring translator into the Python interpreter. If the user input:

Re: the address of list.append and list.append.__doc__

2007-09-26 Thread HYRY
> There's no such thing as an "original method" - what's stored as an > attribute of the class is a plain function. FWIW, you can get at this > function quite easily - via the im_func attribute of the method. I know about im_func, but I tried the im_func attribute of append and I get error: 'built

why scipy cause my program slow?

2007-01-16 Thread HYRY
Why the exec time of test(readdata()) and test(randomdata()) of following program is different? my test file 150Hz10dB.wav has 2586024 samples, so I set randomdata function to return a list with 2586024 samples. the exec result is: 2586024 10.8603842736 2586024 2.16525233979 test(randomdata()) is

Re: why scipy cause my program slow?

2007-01-16 Thread HYRY
Thanks, by your hint, I change type(data) to type(data[0]), and I get So, calculate with float is about 5x faster numpy.float64. Robert Kern wrote: > HYRY wrote: > > Why the exec time of test(readdata()) and test(randomdata()) of > > following program is different? &

Re: python recursive function

2008-01-11 Thread HYRY
> def bears (n): > if n==42: > return True > if n%5==0: > bears(n-42) > if n%2==0: > bears(n/2) > if n%3==0 or n%4==0: > one = (n%10) > two = ((n%100)/10) > if one!=0 and two!=0: > bears(n-(one*two)) > return False > >

How to add function return value

2008-05-30 Thread HYRY
I need to write functions that return locals() as follows, def func1(): a = 1 return locals() def func2(): b = 2 return locals() Can I write a decorator that it can automately do this conversion def func1() a = 1 ---> def func1(): a = 1 return locals() -- http://ma