Tino Dai wrote: > Hi Everybody, > > I'm having some problems with get an if block to work. > > import re > > regex=re.compile('(some expression)') > > # What I'm trying to get to work > if (m=regex.search('some long string')): > print m.groups() > > - The thing that isn't working is the m=regex .... in the if line. Is this > possible in python?
No. Assignment in Python is a statement, not an expression. It does not have a value and it can't be used in a conditional. Use m=regex.search('some long string') if (m): print m.groups() Kents _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor