Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #101741
| From | Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Powerful perl paradigm I don't find in python |
| Date | 2016-01-15 11:42 +0100 |
| Message-ID | <mailman.5.1452854573.15297.python-list@python.org> (permalink) |
| References | <n7adse$k6$1@dont-email.me> <n7af0o$kfr$1@ger.gmane.org> |
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 you a lot more responses.
If I'm guessing correctly what the snippet is supposed to do (and, yes,
my Perl definitely is rusty), isn't the Python equivalent of the regex
part of your question fairly obvious if you're using the re module:
things = []
while some_str != tail:
m = re.match(pattern_str, some_str)
things.append(some_str[:m.end()])
some_str = some_str[m.end():]
# do something with things
I have no idea why you'd want to *import* all the things parsed out of
some_str, but for this part you may look at importlib.import_module.
P.S.: the while loop above never ends if tail is not in some_str, but I
guess your Perl snippet has the same problem?
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Powerful perl paradigm I don't find in python "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2016-01-15 09:24 +0000
Re: Powerful perl paradigm I don't find in python Peter Otten <__peter__@web.de> - 2016-01-15 10:43 +0100
Re: Powerful perl paradigm I don't find in python Michael Vilain <vilain@NOspamcop.net> - 2016-01-15 02:20 -0800
Re: Powerful perl paradigm I don't find in python Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2016-01-15 11:42 +0100
Re: Powerful perl paradigm I don't find in python "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2016-01-15 11:04 +0000
Re: Powerful perl paradigm I don't find in python "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2016-01-15 11:06 +0000
Re: Powerful perl paradigm I don't find in python Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2016-01-15 14:20 +0100
Re: Powerful perl paradigm I don't find in python "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2016-01-18 13:05 +0000
Re: Powerful perl paradigm I don't find in python Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2016-01-18 14:33 +0100
Re: Powerful perl paradigm I don't find in python Peter Otten <__peter__@web.de> - 2016-01-15 14:34 +0100
Re: Powerful perl paradigm I don't find in python Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2016-01-15 13:51 +0000
Re: Powerful perl paradigm I don't find in python me <self@example.org> - 2016-01-15 15:20 +0000
Re: Powerful perl paradigm I don't find in python Nathan Hilterbrand <nhilterbrand@gmail.com> - 2016-01-15 11:54 -0500
csiph-web