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: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.020 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'andres': 0.09; 'list)': 0.09; 'subject:string': 0.09; 'am,': 0.12; 'cc:addr:python-list': 0.15; 'str)': 0.16; 'subject:variable': 0.16; 'wrote:': 0.16; 'wed,': 0.17; '>>>': 0.18; '(which': 0.19; 'subject:list': 0.21; 'feb': 0.22; 'header:In-Reply-To:1': 0.22; 'received:209.85.212.46': 0.23; 'received:mail- vw0-f46.google.com': 0.23; 'cc:2**0': 0.25; 'function': 0.27; "i'm": 0.27; 'lists': 0.28; 'message-id:@mail.gmail.com': 0.28; 'elements': 0.28; 'cc:addr:python.org': 0.29; 'class': 0.29; 'strings.': 0.30; 'subject:?': 0.30; 'list': 0.32; 'received:209.85.212': 0.34; 'hi,': 0.34; 'thank': 0.35; 'subject:How': 0.35; 'element': 0.36; 'but': 0.37; 'received:google.com': 0.37; 'subject:can': 0.37; 'received:209.85': 0.38; 'should': 0.38; 'received:209': 0.39; 'subject:: ': 0.39; 'receive': 0.68; 'to:addr:yahoo.com': 0.83; '12:44': 0.84; 'prof.': 0.84; '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:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=hPbRXLFDqecZgev4hmII98Bub+2/T+68hABkI1i1yBs=; b=n3lKiwFFaEyTc+rvIKVAp9D9ARLIK/eTVyvleTA4MhqI0P3I7xIKHbIrzZ2LFwPcPg ZgBzxKc1he3OViEGvXYwjnrpJI6LqUusK68mWRGdepLFofm9j3QN4amf3KqGF5K0UY4k uy6CtZKEWR/Y2HEKT0DziHyt49aZwVaLhXJao= MIME-Version: 1.0 In-Reply-To: <1328057052.56088.YahooMailNeo@web30601.mail.mud.yahoo.com> References: <1328057052.56088.YahooMailNeo@web30601.mail.mud.yahoo.com> From: Noah Hall Date: Wed, 1 Feb 2012 00:58:20 +0000 Subject: Re: How can I verify if the content of a variable is a list or a string? To: Andres Soto Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: "python-list@python.org" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1328057942 news.xs4all.nl 6852 [2001:888:2000:d::a6]:41880 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:19670 On Wed, Feb 1, 2012 at 12:44 AM, Andres Soto wrote: > Hi, > I'm writing a function which receive a list which elements are strings or > new lists (sublists) containing strings. > How can I verify if sone element of the list (which is contained in a > variable) is a list or a string? > I found the method isinstance(object,class) but I don't know which class > should I use for. > Thank you, regards > > Prof. Dr.=A0Andr=E9s Soto > DES DACI > UNACAR "list" and "str" >>> my_list =3D [1, 2, 3] >>> isinstance(my_list, list) True >>> my_string =3D "foobar" >>> isinstance(my_string, str) True