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


Groups > comp.lang.python > #19700

Re: How can I verify if the content of a variable is a list or a string?

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!tudelft.nl!txtfeed1.tudelft.nl!multikabel.net!newsfeed20.multikabel.net!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'python': 0.08; 'andres': 0.09; 'interpreter,': 0.09; 'subject:string': 0.09; 'received:209.85.210.174': 0.13; 'received:mail- iy0-f174.google.com': 0.13; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'handy': 0.16; 'literal,': 0.16; 'subject:variable': 0.16; 'wrote:': 0.16; 'wed,': 0.17; '>>>': 0.18; 'tells': 0.21; 'subject:list': 0.21; 'feb': 0.22; 'header :In-Reply-To:1': 0.22; 'string': 0.24; 'pm,': 0.26; 'message- id:@mail.gmail.com': 0.28; 'times.': 0.30; 'object.': 0.30; 'you!!': 0.30; 'subject:?': 0.30; 'quite': 0.31; 'to:addr:python- list': 0.33; 'there': 0.33; 'thank': 0.35; 'subject:How': 0.35; 'but': 0.37; 'received:google.com': 0.37; 'using': 0.37; 'subject:can': 0.37; 'received:209.85': 0.38; 'received:209': 0.39; 'subject:: ': 0.39; 'to:addr:python.org': 0.40; 'type': 0.60; 'subject:content': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=oFX1/mDy6HJRowJjJAIqQfk+jQrHfACAPbPvtl5KwT0=; b=inA+BTbYDD1YRwqxx+KWj6XpOB+xingBij298wTCGdc05Pt7L1uAih4KFAaPgbYqfq K+zPyan7GIE4S71Sq7NJloL/PcmGgmdLMs/+qTBmGgZHW8NOSmOGcfOvnoOSnOhYVRjH HIuf2Bj/uDvK+jwl5jX+AF4Kp6ya72gXRC8YQ=
MIME-Version 1.0
In-Reply-To <1328058665.56641.YahooMailNeo@web30607.mail.mud.yahoo.com>
References <1328057052.56088.YahooMailNeo@web30601.mail.mud.yahoo.com> <CAOv69sb2e0Aj-v5zM8iczPt2DAGtFZHmHgZBWPdCqnLfre0+dw@mail.gmail.com> <1328058665.56641.YahooMailNeo@web30607.mail.mud.yahoo.com>
Date Wed, 1 Feb 2012 20:48:50 +1100
Subject Re: How can I verify if the content of a variable is a list or a string?
From Chris Angelico <rosuav@gmail.com>
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.5293.1328089733.27778.python-list@python.org> (permalink)
Lines 17
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1328089733 news.xs4all.nl 6949 [2001:888:2000:d::a6]:40773
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:19700

Show key headers only | View raw


On Wed, Feb 1, 2012 at 12:11 PM, Andres Soto <soto_andres@yahoo.com> wrote:
>
> okok, my mistake is that I was using string in place of str. Thank you!!
> regards

Tip: In the interactive interpreter, enter:

>>> type("spam")
<class 'str'>

In Python 2, it'll say "type" not "class", but same diff. It tells you
there what the type is.

Same can be used for any other literal, name, or other object. Can be
quite handy at times.

ChrisA

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


Thread

Re: How can I verify if the content of a variable is a list or a string? Chris Angelico <rosuav@gmail.com> - 2012-02-01 20:48 +1100

csiph-web