Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.straub-nv.de!goblin3!goblin1!goblin.stu.neva.ru!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.029 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'python': 0.09; 'nameerror:': 0.09; 'str)': 0.09; 'oct': 0.16; '>>>': 0.18; 'import': 0.21; '"",': 0.22; 'defined': 0.22; '(most': 0.27; 'message-id:@mail.gmail.com': 0.27; 'regular': 0.27; 'skip:_ 10': 0.29; 'file': 0.32; 'traceback': 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'object': 0.38; 'to:addr:python.org': 0.39; 'more': 0.63; 'type(s)': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=BULwsN26759Tr2k6epAZKU+PdwzHhL2Atu10WLBPHd4=; b=JnaZsud+RgLoFMVtU5DSpXzj5g3RFfyMyQhFW120mC5dGbD421bjhxXJ3I7hXT+zIL 1shQRwuznEqa2Q0dWlcYTjC8RCgPY4ClvIzmj5PCR4oTEuiqQnXUHXqNBuANdrNFrOyC wkUzPIJcEWwgofAWaB3I00Xp5sOneP4Aa8wSZoe2FWOTXDjiRvn4JM5mlbITFueVhr7D bWz+98eZNYtad9iwUd7PACamzJeKCoFP7aTL07ogYaJYwrkNwBtaqmsPqsuI1zdNabbk pZigBF+1EseoBEALLnx1MTYcoF9NAOaCCyPIDh8CDwwH/VN9bRkzM6XHQVOvF68swgT2 qc9g== MIME-Version: 1.0 X-Received: by 10.50.195.134 with SMTP id ie6mr4412339igc.6.1361082898031; Sat, 16 Feb 2013 22:34:58 -0800 (PST) Date: Sat, 16 Feb 2013 23:34:57 -0700 Subject: Comparing types From: Jason Friedman To: python-list@python.org Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1361082907 news.xs4all.nl 6914 [2001:888:2000:d::a6]:47809 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:39014 I want to tell whether an object is a regular expression pattern. Python 3.2.3 (default, Oct 19 2012, 20:10:41) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import re >>> s = "hello" >>> type(s) >>> isinstance(s, str) True >>> my_pattern = re.compile(s) >>> type(my_pattern) >>> isinstance(my_pattern, _sre.SRE_Pattern) Traceback (most recent call last): File "", line 1, in NameError: name '_sre' is not defined