On Mar 16, 11:56 am, Jean-Michel Pichavant
wrote:
> samb wrote:
> > Hi,
>
> > I've found a work around, inspired from Rob Williscroft :
>
> > class ReMatch(object):
> > """
> > Object to be called :
> > 1st time : do a regexp.match and return the answer (args:
> > regexp, line)
samb wrote:
Hi,
I've found a work around, inspired from Rob Williscroft :
class ReMatch(object):
"""
Object to be called :
1st time : do a regexp.match and return the answer (args:
regexp, line)
2nd time : return the previous result (args: prev)
"""
def __cal
samb a écrit :
Hi,
I've found a work around, inspired from Rob Williscroft :
class ReMatch(object):
"""
Object to be called :
1st time : do a regexp.match and return the answer (args:
regexp, line)
2nd time : return the previous result (args: prev)
"""
def __
samb wrote:
> I've found a work around, inspired from Rob Williscroft :
>
> class ReMatch(object):
> """
> Object to be called :
> 1st time : do a regexp.match and return the answer (args:
> regexp, line)
> 2nd time : return the previous result (args: prev)
> """
>
Hi,
I've found a work around, inspired from Rob Williscroft :
class ReMatch(object):
"""
Object to be called :
1st time : do a regexp.match and return the answer (args:
regexp, line)
2nd time : return the previous result (args: prev)
"""
def __call__(self, rege
On Mar 16, 9:53 am, Chris Rebert wrote:
> On Tue, Mar 16, 2010 at 1:37 AM, samb wrote:
> > Thanks for all those suggestions.
> > They are good!
>
> > 2) Concerning the suggestion :
> > m = re.match(r'define\s+(\S+)\s*{$', line)
> > if m:
> > thing = m.group(1)
>
> > m = re.match(r'include\s+(
samb wrote in news:5c361012-1f7b-487f-915b-0f564b238be3
@e1g2000yqh.googlegroups.com in comp.lang.python:
> Thanks for all those suggestions.
> They are good!
>
> 1) Let's suppose now that instead of just affecting "thing =
> m.group(1)", I need to do a piece of logic depending on which match I
>
On Tue, Mar 16, 2010 at 1:37 AM, samb wrote:
> Thanks for all those suggestions.
> They are good!
> 2) Concerning the suggestion :
> m = re.match(r'define\s+(\S+)\s*{$', line)
> if m:
> thing = m.group(1)
>
> m = re.match(r'include\s+(\S+)$', line)
> if m:
> thing = m.group(1)
>
> #etc...
>
Thanks for all those suggestions.
They are good!
1) Let's suppose now that instead of just affecting "thing =
m.group(1)", I need to do a piece of logic depending on which match I
entered...
2) Concerning the suggestion :
m = re.match(r'define\s+(\S+)\s*{$', line)
if m:
thing = m.group(1)
m
samb wrote:
Hi,
I'm trying to do something like :
if m = re.match(r'define\s+(\S+)\s*{$', line):
thing = m.group(1)
elif m = re.match(r'include\s+(\S+)$', line):
thing = m.group(1)
else
thing = ""
But in fact I'm not allowed to affect a variable in "if" statement.
My code should th
samb writes:
> or like :
>
> m = re.match(r'define\s+(\S+)\s*{$', line)
> if m:
> thing = m.group(1)
> else:
> m = re.match(r'include\s+(\S+)$', line)
> if m:
> thing = m.group(1)
> else
> thing = ""
>
> Which isn't nice neither because I'm going to have maybe 20 ma
On Tue, Mar 16, 2010 at 12:45 AM, samb wrote:
> Hi,
>
> I'm trying to do something like :
>
> if m = re.match(r'define\s+(\S+)\s*{$', line):
> thing = m.group(1)
> elif m = re.match(r'include\s+(\S+)$', line):
> thing = m.group(1)
> else
> thing = ""
>
> But in fact I'm not allowed to aff
Hi,
I'm trying to do something like :
if m = re.match(r'define\s+(\S+)\s*{$', line):
thing = m.group(1)
elif m = re.match(r'include\s+(\S+)$', line):
thing = m.group(1)
else
thing = ""
But in fact I'm not allowed to affect a variable in "if" statement.
My code should then look like :
13 matches
Mail list logo