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


Groups > comp.lang.python > #42244

Re: Doing both regex match and assignment within a If loop?

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <msirenef@lightbird.net>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.015
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'subject:both': 0.07; 'python:': 0.09; 'def': 0.12; 'name)': 0.16; 'name):': 0.16; 'received:74.55.86': 0.16; 'received:74.55.86.74': 0.16; 'received:smtp.webfaction.com': 0.16; 'received:webfaction.com': 0.16; 'wrote:': 0.18; 'import': 0.22; 'this?': 0.23; 'header:User- Agent:1': 0.23; 'simpler': 0.24; 'gets': 0.27; 'header:In-Reply- To:1': 0.27; 'am,': 0.29; 'george': 0.31; 'received:192.168.1.3': 0.31; 'class': 0.32; 'skip:_ 10': 0.34; '(2)': 0.35; 'subject:?': 0.36; 'to:addr:python-list': 0.38; 'little': 0.38; 'to:addr:python.org': 0.39; 'soul': 0.74; 'belief': 0.84; 'otten': 0.84
Date Fri, 29 Mar 2013 09:49:34 -0400
From Mitya Sirenef <msirenef@lightbird.net>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130308 Thunderbird/17.0.4
MIME-Version 1.0
To python-list@python.org
Subject Re: Doing both regex match and assignment within a If loop?
References <f8598e49-67af-4a97-98db-9fd69d0182ae@googlegroups.com> <kj3j8n$urg$1@ger.gmane.org>
In-Reply-To <kj3j8n$urg$1@ger.gmane.org>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3947.1364564977.2939.python-list@python.org> (permalink)
Lines 27
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1364564977 news.xs4all.nl 6938 [2001:888:2000:d::a6]:35285
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:42244

Show key headers only | View raw


On 03/29/2013 04:27 AM, Peter Otten wrote:
> (2)
 > import re
 >
 > class Matcher:
 >     def __call__(self, expr, line):
 >         result = self.match = expr.match(line)
 >         return result
 >     def __getattr__(self, name):
 >         return getattr(self.match, name)


Perhaps it's a little simpler to do this?

>         self.match =  expr.match(line)
 >         return self.match


  -m


-- 
Lark's Tongue Guide to Python: http://lightbird.net/larks/

Frisbeetarianism is the belief that when you die, your soul goes up on
the roof and gets stuck.  George Carlin

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


Thread

Doing both regex match and assignment within a If loop? Victor Hooi <victorhooi@gmail.com> - 2013-03-28 21:00 -0700
  Re: Doing both regex match and assignment within a If loop? Chris Rebert <clp2@rebertia.com> - 2013-03-28 21:29 -0700
  Re: Doing both regex match and assignment within a If loop? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-29 06:45 +0000
  Re: Doing both regex match and assignment within a If loop? Peter Otten <__peter__@web.de> - 2013-03-29 09:27 +0100
  Re: Doing both regex match and assignment within a If loop? Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2013-03-29 11:06 +0100
    Re: Doing both regex match and assignment within a If loop? Arnaud Delobelle <arnodel@gmail.com> - 2013-03-29 10:41 +0000
    Re: Doing both regex match and assignment within a If loop? Neil Cerutti <neilc@norwich.edu> - 2013-03-29 12:51 +0000
  Re: Doing both regex match and assignment within a If loop? Mitya Sirenef <msirenef@lightbird.net> - 2013-03-29 09:49 -0400

csiph-web