On Thu, 17 Nov 2005 10:03:50 GMT, Rikard Bosnjakovic <[EMAIL PROTECTED]> wrote:
>I'm tidying up some code. Basically, the code runs a bunch of
>regexp-searches (> 10) on a text and stores the match in a different variable.
>
>Like this:
>
> re1 = r' ..(.*).. '
> re2 = r' '
> re3
On Thu, 17 Nov 2005 12:31:08 -0800,
[EMAIL PROTECTED] (Alex Martelli) wrote:
> Dan Sommers <[EMAIL PROTECTED]> wrote:
>...
>> Put the results into a dictionary (untested code follows!):
[ example code snipped ]
>> Now you can access the results as results['foo'], etc. Or look up
>> the Borg
Dan Sommers <[EMAIL PROTECTED]> wrote:
...
> Put the results into a dictionary (untested code follows!):
>
> l = [ (re1, 'bar'),
> (re2, 'foo'),
> (re3, 'baz'),
> ]
> results = {}
> for (regexp, key) in l:
> m = re.search(regexp, data)
> i
On Thu, 17 Nov 2005 10:03:50 GMT,
Rikard Bosnjakovic <[EMAIL PROTECTED]> wrote:
> What I want is to rewrite it to something like this:
> l = [ (re1, myclass.bar),
> (re2, myclass.foo),
> (re3, myclass.baz),
> ]
> for (x,y) in l:
> m = re.search(x, y)
>
Rikard Bosnjakovic wrote:
> I'm tidying up some code. Basically, the code runs a bunch of
> regexp-searches (> 10) on a text and stores the match in a different variable.
>
> Like this:
>
> re1 = r' ..(.*).. '
> re2 = r' '
> re3 = r' .(.*).. '
> ...
> m = re.search(re
I'm tidying up some code. Basically, the code runs a bunch of
regexp-searches (> 10) on a text and stores the match in a different variable.
Like this:
re1 = r' ..(.*).. '
re2 = r' '
re3 = r' .(.*).. '
...
m = re.search(re1, data)
if m:
myclass.bar = m.g