Re: Need help in Python regular expression

2009-06-11 Thread meryl
On Jun 11, 9:41 pm, "Mark Tolonen" wrote: > "meryl" wrote in message > > news:2d4d8624-043b-4f5f-ae2d-bf73bca3d...@p6g2000pre.googlegroups.com... > > > > > > > Hi, > > > I have this regular expression > > blockRE = re.compile(&

Need help in Python regular expression

2009-06-11 Thread meryl
Hi, I have this regular expression blockRE = re.compile(".*RenderBlock {\w+}") it works if my source is "RenderBlock {CENTER}". But I want it to work with 1. RenderTable {TABLE} So i change the regexp to re.compile(".*Render[Block|Table] {\w+}"), but that breaks everything 2. RenderBlock (CENT

Re: Need help in understanding a python code

2008-11-15 Thread Meryl Silverburgh
This is the full source code: def A(w, v, i,j): if i == 0 or j == 0: return 0 if w[i-1] > j: return A(w, v, i-1, j) if w[i-1] <= j: return max(A(w,v, i-1, j), v[i-1] + A(w,v, i-1, j - w[i-1])) I am reading this blog http://20bits.com/articles/introduction-to-dynamic-programming/ On

Walk thru each subdirectory from a top directory

2007-02-26 Thread silverburgh . meryl
i am trying to use python to walk thru each subdirectory from a top directory. Here is my script: savedPagesDirectory = "/home/meryl/saved_pages/data" dir=open(savedPagesDirectory, 'r') for file in dir: if (isdir(file)): # get the full path of the f

Re: How to call a function defined in another py file

2007-02-19 Thread silverburgh . meryl
On Feb 19, 2:22 pm, "Martin Blume" <[EMAIL PROTECTED]> wrote: > <[EMAIL PROTECTED]> schrieb > > > I have a function called 'test' defined in A.py. > > How can I call that function test in my another file B.py? > > In B.py: > > import A > > A.test() > > HTH > Martin But Do I need to put A.py and B.

How to call a function defined in another py file

2007-02-19 Thread silverburgh . meryl
Hi, I have a function called 'test' defined in A.py. How can I call that function test in my another file B.py? Thank you. -- http://mail.python.org/mailman/listinfo/python-list

Question about strftime

2007-02-10 Thread silverburgh . meryl
Hi, I have question about strftime. I am trying to print the current time in this format: date = strftime("%Y%m%d_%H%M%S", gmtime()) print date I run the script at 2:18 pm, but I get this: 20070210_201837 Can you please tell me why I get '20'? instead of '14' (which is 2:00 pm)? Thank you. -

Use python to process XML file

2006-03-10 Thread silverburgh . meryl
Hi, Can you please tell me how Use python to process XML file? The example I find is build a DOM, but I just need to do it in SAX based, how can I do that? For example, I have a xml file like this: text text text text text text text For i want to process the node in the order they

UnboundLocalError: local variable 'colorIndex' referenced

2006-02-26 Thread silverburgh . meryl
Can you please tell me what is the meaning this error in general? UnboundLocalError: local variable 'colorIndex' referenced before assignment In my python script, I have a variable define and init to 0, like this colorIndex = 0 and in one of my functions, I increment it by 1 def myFunc co

Re: How can I find the remainder when dividing 2 integers

2006-02-26 Thread silverburgh . meryl
Can you please tell me what is the meaning of UnboundLocalError: local variable 'colorIndex' referenced before assignment in general? -- http://mail.python.org/mailman/listinfo/python-list

Re: How can I find the remainder when dividing 2 integers

2006-02-26 Thread silverburgh . meryl
okay, I try you suggestion, and re-write my code like this: colors = ["#ff", "#00FF00", "#FF"] colorIndex = 0 def getText(nodelist): for str in strings: print colors[colorIndex % colors.length] colorIndex += 1 but i get this error

How can I find the remainder when dividing 2 integers

2006-02-26 Thread silverburgh . meryl
I have a string array: colors = ["#ff", "#00FF00", "#FF"] colorIndex = 0; and I want to loop thru each element of colors for str in strings: print colors[colorIndex++ % colors.length] But i get an invalid syntax error when I execute the script: print colors[colorIndex++ % colors.l