Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #101874
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| 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 | Mon, 18 Jan 2016 14:33:45 +0100 |
| Lines | 34 |
| Message-ID | <mailman.87.1453124045.15297.python-list@python.org> (permalink) |
| References | <n7adse$k6$1@dont-email.me> <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> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.uni-berlin.de 0MKfOoTmrW9xwtte+f0ypALwxnIkeuPAMxUUkO3NY4EQ== |
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'matches': 0.07; 'valueerror:': 0.07; 'occurrences': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'simplified': 0.09; 'string)': 0.09; 'subject:don': 0.09; 'jan': 0.11; 'subject:python': 0.14; '14:05,': 0.16; '2016': 0.16; 'adjacent': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'case.': 0.18; 'try:': 0.18; 'ones.': 0.22; 'terminate': 0.22; 'pass': 0.22; 'header:In-Reply-To:1': 0.24; 'software.': 0.25; 'header:User-Agent:1': 0.26; 'example': 0.26; 'header:X-Complaints-To:1': 0.26; 'equivalent': 0.27; 'fri,': 0.27; '---': 0.28; 'initial': 0.28; 'figured': 0.29; 'perl': 0.29; 'received:132': 0.29; 'tail': 0.29; 'checked': 0.31; 'file': 0.34; 'except': 0.34; 'something': 0.35; 'totally': 0.36; 'to:addr :python-list': 0.36; 'subject:: ': 0.37; 'expect': 0.37; 'received:org': 0.37; 'version': 0.38; 'skip:p 20': 0.38; 'thank': 0.38; 'skip:e 20': 0.39; 'to:addr:python.org': 0.40; 'your': 0.60; 'great': 0.63; 'you.': 0.64; 'it!': 0.64; 'antivirus': 0.66; 'smith': 0.76; 'avast': 0.84; 'subject:find': 0.91 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| X-Gmane-NNTP-Posting-Host | 132.230.194.220 |
| User-Agent | Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 |
| In-Reply-To | <n7inve$5ut$1@dont-email.me> |
| X-Antivirus | avast! (VPS 160103-1, 01/03/2016), Outbound message |
| X-Antivirus-Status | Clean |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:101874 |
Show key headers only | 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 | 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