newbie question: parse a variable inside an RE?

2008-12-01 Thread joemacbusiness
Hi All, How do I parse a variable inside an RE? What is the re.search() syntax when your search string is a variable? It's easy to parse hardcoded RE's but not if you use a variable. Here is my code, input and runtime: $ cat test45.py #!/usr/bin/python import re resp = raw_input('Selection: ')

newbie question: if var1 == var2:

2008-11-28 Thread joemacbusiness
Hi All, I dont understand why the following code cannot find the variable "tree". It is very simple but I could not find the answer to this on the Python Tutorials. Here is the code, input and runtime: #!/usr/bin/python fname = open("test43.in") var = 'tree' for item in fname: print "item

Re: Need help capturing output of re.search

2008-06-26 Thread joemacbusiness
On Jun 26, 5:12 pm, John Machin <[EMAIL PROTECTED]> wrote: > On Jun 27, 10:01 am, [EMAIL PROTECTED] wrote: > > > >You may like to read this:http://www.amk.ca/python/howto/regex/ > > > This is a good resource.  Thank you. > > Someone else pointed out that I needed to change the > > > if reCheck == "

Re: Need help capturing output of re.search

2008-06-26 Thread joemacbusiness
>You may like to read this: http://www.amk.ca/python/howto/regex/ This is a good resource. Thank you. Someone else pointed out that I needed to change the if reCheck == "None": to if reCheck == None: # removed the "s This worked great! Thanks! --JM -- http://mail.python.org/mailman/listin

Need help capturing output of re.search

2008-06-26 Thread joemacbusiness
Hi - I need help capturing the output of a RegEx search. I dont understand why this conditional fails. Here is the code: #= start snip == #!/usr/local/bin/python import os import re dirName = '/home/user/bin/logs' os.chdir(dir

Question: How do I format printing in python

2008-06-23 Thread joemacbusiness
Hi All, How do I format printed data in python? I could not find this in the Python Reference Manual: http://docs.python.org/ref/print.html Nor could I find it in Matloff's great tutorial: http://heather.cs.ucdavis.edu/~matloff/Python/PythonIntro.pdf For example, how do I turn this: 512 Jun 5 2