Re: Powerful perl paradigm I don't find in python

2016-01-18 Thread Wolfgang Maier
On 1/18/2016 14:05, Charles T. Smith wrote: On Fri, 15 Jan 2016 14:20:17 +0100, Wolfgang Maier wrote: pattern = pattern_str.compile() try: matches = pattern.findall(some_str, endpos=some_str.index(tail)) except ValueError: # do something if tail is not found pass Oh! I thin

Re: Powerful perl paradigm I don't find in python

2016-01-18 Thread Charles T. Smith
On Fri, 15 Jan 2016 14:20:17 +0100, Wolfgang Maier wrote: > pattern = pattern_str.compile() > try: > matches = pattern.findall(some_str, endpos=some_str.index(tail)) > except ValueError: > # do something if tail is not found > pass Oh! I think that's it! matches = findall (patte

Re: Powerful perl paradigm I don't find in python

2016-01-15 Thread Nathan Hilterbrand
On 01/15/2016 04:24 AM, Charles T. Smith wrote: while ($str != $tail) { $str ~= s/^(head-pattern)//; use ($1); } IDK... maybe the OP is looking for something like this? : import re def do_something(matchobj): print("I found {}".format(matchobj.group(0))) return "" tail =

Re: Powerful perl paradigm I don't find in python

2016-01-15 Thread me
On 2016-01-15, Ulli Horlacher wrote: > Charles T. Smith wrote: >> while ($str != $tail) { >> $str ~= s/^(head-pattern)//; >> use ($1); >> } > > use() is illegal syntax in Perl. Actually it is not. OP is defnitely thinking of `use` as a placeholder for some general use of the value $1. I

Re: Powerful perl paradigm I don't find in python

2016-01-15 Thread Ulli Horlacher
Charles T. Smith wrote: > while ($str != $tail) { > $str ~= s/^(head-pattern)//; > use ($1); > } use() is illegal syntax in Perl. -- Ullrich Horlacher Server und Virtualisierung Rechenzentrum IZUS/TIK E-Mail: horlac...@tik.uni-stuttgart.de Universitaet Stuttgart

Re: Powerful perl paradigm I don't find in python

2016-01-15 Thread Peter Otten
Charles T. Smith wrote: > What the original snippet does is parse *and consume* a string - actually, > to avoid maintaining a cursor traverse the string. The perl feature is > that substitute allows the found pattern to be replaced, but retains the > group after the expression is complete. That

Re: Powerful perl paradigm I don't find in python

2016-01-15 Thread Wolfgang Maier
On 15.01.2016 12:04, Charles T. Smith wrote: On Fri, 15 Jan 2016 11:42:24 +0100, Wolfgang Maier wrote: On 15.01.2016 10:43, Peter Otten wrote: Charles T. Smith wrote: while ($str != $tail) { $str ~= s/^(head-pattern)//; use ($1); } things = [] while some_str != tail:

Re: Powerful perl paradigm I don't find in python

2016-01-15 Thread Charles T. Smith
On Fri, 15 Jan 2016 11:42:24 +0100, Wolfgang Maier wrote: > On 15.01.2016 10:43, Peter Otten wrote: >> Charles T. Smith wrote: >> >>> while ($str != $tail) { >>> $str ~= s/^(head-pattern)//; >>> use ($1); >>> } >> > > things = [] > while some_str != tail: > m = re.match(patter

Re: Powerful perl paradigm I don't find in python

2016-01-15 Thread Charles T. Smith
On Fri, 15 Jan 2016 11:04:32 +, Charles T. Smith wrote: > capability, somehow, but that was apparently overlooked. For example, > by storing string state in the match object and having a *sub* method without > a string parameter. -- https://mail.python.org/mailman/listinfo/python-list

Re: Powerful perl paradigm I don't find in python

2016-01-15 Thread Wolfgang Maier
On 15.01.2016 10:43, Peter Otten wrote: Charles T. Smith wrote: while ($str != $tail) { $str ~= s/^(head-pattern)//; use ($1); } For those whose Perl's a little rusty: what does this do? A self-contained example might also be useful... Right, an explanation would certainly get yo

Re: Powerful perl paradigm I don't find in python

2016-01-15 Thread Peter Otten
Charles T. Smith wrote: > while ($str != $tail) { > $str ~= s/^(head-pattern)//; > use ($1); > } For those whose Perl's a little rusty: what does this do? A self-contained example might also be useful... -- https://mail.python.org/mailman/listinfo/python-list

Powerful perl paradigm I don't find in python

2016-01-15 Thread Charles T. Smith
while ($str != $tail) { $str ~= s/^(head-pattern)//; use ($1); } -- https://mail.python.org/mailman/listinfo/python-list