Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #101874

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

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-18 14:33 +0100
Message-ID <mailman.87.1453124045.15297.python-list@python.org> (permalink)
References (1 earlier) <n7af0o$kfr$1@ger.gmane.org> <mailman.5.1452854573.15297.python-list@python.org> <n7ajo0$k6v$1@dont-email.me> <mailman.11.1452864029.15297.python-list@python.org> <n7inve$5ut$1@dont-email.me>

Show all headers | View raw


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 think that's it!
>
>
> matches = findall (pattern, string)
> for file in matches:
>      use (file)
>
> Totally cool!  Thank you.
>

Great if it helps you. Just beware that this simplified version is not 
exactly equivalent to your initial perl snippet:

Generally, findall will find ALL occurrences of pattern, not just 
adjacent ones.

Since your perl example would never terminate if something non-matching 
is interleaved with pattern matches I figured you never expect that case.

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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