Re: Simulating call-by-reference

2005-11-17 Thread Bengt Richter
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

Re: Simulating call-by-reference

2005-11-17 Thread Dan Sommers
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

Re: Simulating call-by-reference

2005-11-17 Thread Alex Martelli
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

Re: Simulating call-by-reference

2005-11-17 Thread Dan Sommers
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) >

Re: Simulating call-by-reference

2005-11-17 Thread [EMAIL PROTECTED]
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

Simulating call-by-reference

2005-11-17 Thread Rikard Bosnjakovic
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