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


Groups > comp.lang.python > #18068

Re: Type object returned by the re.compile function

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.007
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'assign': 0.04; 'subject:object': 0.07; 'python': 0.08; 'mentions': 0.09; 'though:': 0.09; '2.7': 0.13; 'invoked.': 0.16; 'subject:function': 0.16; 'url:html#re': 0.16; 'received:74.125.82.44': 0.16; 'received:mail-ww0-f44.google.com': 0.16; 'meant': 0.17; 'wrote:': 0.18; '>>>': 0.18; 'instance': 0.18; 'seems': 0.20; 'cheers,': 0.20; 'dec': 0.22; "doesn't": 0.22; 'header:In-Reply-To:1': 0.22; 'specify': 0.24; 'module': 0.26; 'import': 0.27; 'message-id:@mail.gmail.com': 0.28; '27,': 0.29; 'pm,': 0.29; 'class': 0.29; 'url:library': 0.31; 'tue,': 0.32; 'object': 0.33; 'to:addr:python-list': 0.34; 'function.': 0.34; 'received:74.125.82': 0.35; 'regular': 0.35; 'url:python': 0.36; 'but': 0.37; 'received:74.125': 0.37; 'received:google.com': 0.37; 'returned': 0.39; 'url:docs': 0.39; 'url:org': 0.39; 'should': 0.39; "it's": 0.40; 'to:addr:python.org': 0.40; 'type': 0.61; 'according': 0.61; '2011': 0.61; 'here': 0.65; 'here:': 0.66; 'candide': 0.84; 'presumably': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=DvifP5KtTv5Q4JPdvuTn6r3+16I/ooArrS51uCDngOM=; b=uVjGyGzg0iGKfT/UAnXODnRK3k/0V4QiWET3etaIDnUMdg8jOU3B2kj34+v86isVcA 7pds02cUlFP1/lQWKq0WMG7CMe9F8xfztw71Klo4rndiPKSLmpZ46yKFBP76Zm0MrIvx QxSAsm9xHfzVj5wSzSt++c1SGUc4ygBkEEZZg=
MIME-Version 1.0
In-Reply-To <4efa3f05$0$6546$426a74cc@news.free.fr>
References <4efa3f05$0$6546$426a74cc@news.free.fr>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Tue, 27 Dec 2011 15:31:30 -0700
Subject Re: Type object returned by the re.compile function
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
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.4159.1325025123.27778.python-list@python.org> (permalink)
Lines 27
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1325025123 news.xs4all.nl 6975 [2001:888:2000:d::a6]:55522
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:18068

Show key headers only | View raw


On Tue, Dec 27, 2011 at 2:56 PM, candide <candide@free.invalid> wrote:
> The Python 2.7 official documentation here:
>
> http://docs.python.org/library/re.html#re.compile
>
> doesn't specify the type object returned by the re.compiled function.
> According to the documentation, re.compile returns a "regular expression
> object".
>
> A regular expression object seems to be an instance of the class
> RegexObject. The documentation mentions this class here :
>
> http://docs.python.org/library/re.html#regular-expression-objects
>
> but i don't see any existing class with this name :

Presumably if it's not in the module then it's not meant to be
directly invoked.  You should always use re.compile().  If you really
want to assign the type a name, though:

>>> import re
>>> RegexObject = type(re.compile(''))
>>> RegexObject
<type '_sre.SRE_Pattern'>

Cheers,
Ian

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


Thread

Type object returned by the re.compile function candide <candide@free.invalid> - 2011-12-27 22:56 +0100
  Re: Type object returned by the re.compile function Jerry Hill <malaclypse2@gmail.com> - 2011-12-27 17:29 -0500
  Re: Type object returned by the re.compile function Ian Kelly <ian.g.kelly@gmail.com> - 2011-12-27 15:31 -0700

csiph-web