[Tutor] How to substitute an element of a list as a pattern for
ps_python at yahoo.com
Thu Dec 30 02:01:23 CET 2004
I have Question:
How can I substitute an object as a pattern in making
>>> x = 30
>>> pattern = re.compile(x)
I have a list of numbers that I have to match in
another list and write them to a new file:
List 1: range_cors
['161:378', '334:3', '334:4', '65:436']
List 2: seq
A slow method:
>>> sequences = 
>>> for elem1 in range_cors:
for index,elem2 in enumerate(seq):
if elem1 in elem2:
This process is very slow and it is taking a lot of
time. I am not happy.
A faster method (probably):
>>> for i in range(len(range_cors)):
for index,m in enumerate(seq):
pat = re.compile(i)
I am getting errors, because I am trying to create an
element as a pattern in re.compile().
1. Is it possible to do this. If so, how can I do
Can any one help correcting my piece of code and
suggesting where I went wrong.
Thank you in advance.
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
More information about the Tutor