Re: What's wrong with my python? I can't use string

2009-02-09 Thread Frank Potter
On Feb 10, 3:20 pm, Chris Rebert wrote: > On Mon, Feb 9, 2009 at 11:13 PM, Frank Potter wrote: > > I have a xxx.py which has code as below: > > > import string > > > print dir(string) > > print string.printable > > > when I run it, I got the strange er

What's wrong with my python? I can't use string

2009-02-09 Thread Frank Potter
I have a xxx.py which has code as below: import string print dir(string) print string.printable when I run it, I got the strange error: "\n" "\n" "##result##\n" "##msg##\n" "##pass_no##\n" "##pot_num##\n" "##pots_mashed##\n" "##yb_used##\n" "##right##\n" "\n" ['__builtins__', '__doc__', '__fil

how to transfer integer on socket?

2007-04-20 Thread Frank Potter
Is there any easy way to transfer 4 bit integer on socket? I want to send like this: a=5 send_integer(socket_s,a) and receive like this: a=receive_integer(socket_s) Sending and receiving is in binary form, not transfer it to string. Is there any easy way to do this? -- http://mail.python.org/

failed to install PIL in fedora core 6

2007-02-23 Thread Frank Potter
I use "python setup.py install" to install PIL in fedora with python 2.4, But I got these errors: running build_ext building '_imaging' extension creating build/temp.linux-i686-2.4 creating build/temp.linux-i686-2.4/libImaging gcc -pthread -fno-strict-aliasing -DNDEBUG -O2 -g -pipe -Wall -Wp,- D_FO

Any python scripts to do parallel downloading?

2007-01-31 Thread Frank Potter
I want to find a multithreaded downloading lib in python, can someone recommend one for me, please? Thanks~ -- http://mail.python.org/mailman/listinfo/python-list

Re: extracting from web pages but got disordered words sometimes

2007-01-27 Thread Frank Potter
Thank you, I tried again and I figured it out. That's something with beautiful soup, I worked with it a year ago also dealing with Chinese html pages and nothing error happened. I read the old code and I find the difference. Change the page to unicode before feeding to beautiful soup, then every

extracting from web pages but got disordered words sometimes

2007-01-27 Thread Frank Potter
There are ten web pages I want to deal with. from http://www.af.shejis.com/new_lw/html/125926.shtml to http://www.af.shejis.com/new_lw/html/125936.shtml Each of them uses the charset of Chinese "gb2312", and firefox displays all of them in the right form, that's readable Chinese. My job is,

Re: how to remove c++ comments from a cpp file?

2007-01-26 Thread Frank Potter
Thank you! On Jan 26, 6:34 pm, Gabriel Genellina <[EMAIL PROTECTED]> wrote: > At Friday 26/1/2007 06:54, Frank Potter wrote: > > >[CODE] > >import re > > >f=open("show_btchina.user.js","r").read() > >f=unicode(f,"utf8") > &

Re: how to remove c++ comments from a cpp file?

2007-01-26 Thread Frank Potter
On Jan 26, 5:08 pm, Gary Herron <[EMAIL PROTECTED]> wrote: > Frank Potter wrote: > > I only want to remove the comments which begin with "//". > > I did like this, but it doesn't work. > > > r=re.compile(ur"//[^\r\n]+$", re.UNICODE|re.VE

how to remove c++ comments from a cpp file?

2007-01-26 Thread Frank Potter
I only want to remove the comments which begin with "//". I did like this, but it doesn't work. r=re.compile(ur"//[^\r\n]+$", re.UNICODE|re.VERBOSE) f=file.open("mycpp.cpp","r") f=unicode(f,"utf8") r.sub(ur"",f) Will somebody show me the right way? Thanks~~ -- http://mail.python.org/mailman/lis

Is any python like linux shell?

2007-01-21 Thread Frank Potter
I learned some python in windows. And now I've turned to linux. I read a book and it teaches how to write shell script with bash, but I don't feel like the grammar of bash. Since I know about python, I want to get a linux shell which use python grammar. I searched by google and I found pysh, which

how to write unicode to a txt file?

2007-01-17 Thread Frank Potter
I want to change an srt file to unicode format so mpalyer can display Chinese subtitles properly. I did it like this: txt=open('dmd-guardian-cd1.srt').read() txt=unicode(txt,'gb18030') open('dmd-guardian-cd1.srt','w').write(txt) But it seems that python can't directly write unicode to a file, I g

Re: where is python on linux?

2007-01-07 Thread Frank Potter
Thank you! "which python" works for me. I got it. Peter Otten wrote: > Frank Potter wrote: > > > I installed fedora core 6 and it has python installed. > > But the question is, where is the executable python file? > > Find out yourself with >

where is python on linux?

2007-01-07 Thread Frank Potter
I installed fedora core 6 and it has python installed. But the question is, where is the executable python file? I can't find it so I come here for help. I want to config pydev for eclipse and I need to know where the ececutable python file is. Thank you! -- http://mail.python.org/mailman/listinf

Re: what are you using python language for?

2006-06-07 Thread Frank Potter
I use python to grab imformations and embed it in my delphi app. I gather what I am intereted in so I can read them faster. And I also use python to do some othere everyday jobs, such as periodically copying and zipping a directory into another computer to backup the comtent. On 7 Jun 2006 16:11:

Re: Regular Expression question

2006-06-07 Thread Frank Potter
pyparsing is cool. but use only re is also OK # -*- coding: UTF-8 -*- import urllib2 html=urllib2.urlopen(ur"http://www.yahoo.com/";).read() import re r=re.compile('[^"]+)"[^>]*>',re.IGNORECASE) for m in r.finditer(html): print m.group('image') I got these rusults: http://us.i1.yimg.com/us.yi

how to login a newsgroup programmely and fetch its emails to read?

2006-04-05 Thread Frank Potter
how to login a newsgroup and get its informations by an account and a password? -- http://mail.python.org/mailman/listinfo/python-list

Re: Delete a file

2006-02-17 Thread Frank Potter
system.remove(filename) On 2/18/06, Sbaush <[EMAIL PROTECTED]> wrote: > Hi. > In my application i create a PNG image and i view it in a frame. > How can delete it from my python code? > Bye... > > -- > Sbaush > -- > http://mail.python.org/mailman/listinfo/python-list > > -- http://mail.python.org

How to *Search* with google from inside my programme and get the search result?

2006-02-14 Thread Frank Potter
I want to search something by a key word from inside my py script. The using google idea comes to my mind first because write a search programme from scratch is not so easy. I want to take advantage of goolge results, but I don't know how. To extract the result from html of google can get the resu

Re: removing characters before writing to file

2006-02-08 Thread Frank Potter
r=re.compile(r"(\(')|( '\))|'")print r.sub('',str(output))On 8 Feb 2006 18:35:01 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: hii have some output that returns a lines of tuples egtr('sometext1', 1421248118, 1, 'P ')('sometext2', 1421248338, 2, 'S ')and so onI tried thisre.sub(r" '() ",

Re: Is Python string immutable?

2005-12-07 Thread Frank Potter
Thank you very much.Steve Holden, I post my soucecode at my blog here:http://hiparrot.wordpress.com/2005/12/08/implementing-a-simple-net-spider/ I wish you can read and give me some suggestion. Any comments will be appreciated.On 12/2/05, Steve Holden < [EMAIL PROTECTED]> wrote:could ildg wrote:> I