Re: A difficulty with lists

2012-08-20 Thread Cheng
On Monday, August 6, 2012 12:50:13 PM UTC-7, Mok-Kong Shen wrote: > I ran the following code: > > > > def xx(nlist): > >print("begin: ",nlist) > >nlist+=[999] > >print("middle:",nlist) > >nlist=nlist[:-1] > >print("final: ",nlist) > > > > u=[1,2,3,4] > > print(u) >

a re problem

2005-05-20 Thread cheng
>>> p.sub('','a\nbc') 'abc' >>> p.sub('','%s') % "a\nbc" 'a\nbc' is it anyone got some idea why it happen? -- http://mail.python.org/mailman/listinfo/python-list

Re: a re problem

2005-05-20 Thread cheng
thx for help :) -- http://mail.python.org/mailman/listinfo/python-list

a html parse problem

2005-05-27 Thread cheng
hi,all if the html like: if i use: def handle_starttag(self, tag, attrs): if tag == 'meta': self.attr = attrs self.headers += ['%s' % (self.attr)] self.attr = '' will get the output: [('name', 'description'), ('content', 'a test page')] [('name', 'keyw

a re problem

2005-05-28 Thread cheng
hi,all, i try to replace every target word found in the text for target in splitText: if stopwords.find(target) >= 0 : text = re.sub(r'\b%s\b','',text) &target when i using the statment: text = re.sub(r'\b%s\b','',text) &target get error : unsupported operand type(s) for &

a dict problem

2005-05-28 Thread cheng
hi all..it a problem about dict: print target, dict[target] get output: keyword {page3.html, page2.html, page1.html} is it some ways to change it to: keyword {page1.html, page2.html, page3.html} -- http://mail.python.org/mailman/listinfo/python-list

need help of RE

2005-05-29 Thread cheng
hi all a string like "(word1 & (Word2|woRd3))" how can i use the re to split it to ['word1', 'word2', 'word3'] -- http://mail.python.org/mailman/listinfo/python-list

Re: need help of RE

2005-05-29 Thread cheng
im sorry, my engilsh is not vell well, the string not only contain '&' and '|' and it can be anyting i just want to split out the "whole word" inside the string -- http://mail.python.org/mailman/listinfo/python-list

Re: need help of RE

2005-05-29 Thread cheng
i try query = query.lower() print re.split(r'\W+',theString) the reslut is : ['', 'word1', 'word2', 'word3', ''] how can i fix the statment to get ['word1', 'word2', 'word3'] -- http://mail.python.org/mailman/listinfo/python-list

Re: need help of RE

2005-05-29 Thread cheng
i try theString= theString.lower() print re.split(r'\W+',theString) the reslut is : ['', 'word1', 'word2', 'word3', ''] how can i fix the statment to get ['word1', 'word2', 'word3'] -- http://mail.python.org/mailman/listinfo/python-list

Re: need help of RE

2005-05-29 Thread cheng
thx for help..i got it now :) -- http://mail.python.org/mailman/listinfo/python-list

when to use import statements in the header, when to use import statements in the blocks where they are used?

2012-02-07 Thread Lei Cheng
Hi all, In a py file, when to use import statements in the header, when to use import statements in the blocks where they are used? What are the best practices? Thanks! Pat -- http://mail.python.org/mailman/listinfo/python-list

Re:Re: Where can I find a lexical spec of python?

2011-09-21 Thread Shaofei Cheng
Yes, I'm using this document now but I was wondering if there is a formal spec for lexical grammar? It looks like some part of the doc "http://docs.python.org/py3k/reference/grammar.html"; is missing. We can find some replacement in lexical_analysis.html but it seems this document is write fo

Getting Python to run Python Scripts in cygwin

2008-06-19 Thread Calvin Cheng
Hi guys, This may be a cygwin issue but I was hoping to get some answers here as well if someone has fixed this problem before. Basically, I am able to run "python .py" python files in command prompt. Unfortunately, I can't seem to get it to work in cygwin. I always get an error that says: pyth

Docutils rst2html.py gives Unknown Directive type "toctree"

2008-06-19 Thread Calvin Cheng
Hi, I am attempting to convert a bunch of .txt files into html using the docutils package. It works for most of the txt files except for the index.txt file which gives 2 errors: (1) Unknown Directive type "toctree" (2) (ERROR/3) Unknown interpreted text role "ref". Any idea how I can fix this?

Re: Web forum (made by python)

2004-12-19 Thread Choe, Cheng-Dae
hon.org/mailman/listinfo/python-list > -- Choe, Cheng-Dae(ììë) Blog: http://www.comdongin.com/ -- http://mail.python.org/mailman/listinfo/python-list

Unable to decode file written by C++ wostringstream

2010-12-23 Thread Yan Cheng CHEOK
nloaded from a web browser. (http://i.imgur.com/l39Lc.png) Is there anything I had missed out? Thanks and Regards Yan Cheng CHEOK -- http://mail.python.org/mailman/listinfo/python-list

automatic multiprocessing

2009-07-07 Thread Cheng Soon Ong
function_inputs: cur_out = function_handle(**kwargs) function_outputs.append(cur_out) Am I missing something here? I cannot seem to get map to pass on keyword arguments. Thanks in advance, Cheng Soon -- http://mail.python.org/mailman/listinfo/python-list

Bit fields in python?

2010-09-06 Thread Kwan Lai Cheng
Hi, I'm trying to rewrite a c program in python & encountered several problems. I have some data structures in my c program like below: typedef struct { unsigned short size; unsigned short reserved:8; unsigned short var_a1:2; unsigned short var_a2:2; unsigned short var_a3:2;

Re: Bit fields in python?

2010-09-07 Thread Kwan Lai Cheng
- Original Message - From: Stefan Behnel To: Sent: Tuesday, September 07, 2010 2:55 PM Subject: Re: Bit fields in python? If you can tell us what these structs are being used for in the original C code, we might be able to point you to a suitable way to implement the same thing eff

Re: Bit fields in python?

2010-09-08 Thread Kwan Lai Cheng
Thanks everyone for all the suggestions! New to python, so reading up on the struct module & Construct library now, hope to get my problem fixed soon. - Original Message - Bitfields are most commonly used for extreme space optimization - i.e. shoving several variables and flags with