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


Groups > comp.lang.python > #19670 > unrolled thread

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

Started byNoah Hall <enalicho@gmail.com>
First post2012-02-01 00:58 +0000
Last post2012-02-01 00:58 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: How can I verify if the content of a variable is a list or a string? Noah Hall <enalicho@gmail.com> - 2012-02-01 00:58 +0000

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

FromNoah Hall <enalicho@gmail.com>
Date2012-02-01 00:58 +0000
SubjectRe: How can I verify if the content of a variable is a list or a string?
Message-ID<mailman.5272.1328057942.27778.python-list@python.org>
On Wed, Feb 1, 2012 at 12:44 AM, Andres Soto <soto_andres@yahoo.com> 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. Andrés Soto
> DES DACI
> UNACAR

"list" and "str"

>>> my_list = [1, 2, 3]
>>> isinstance(my_list, list)
True
>>> my_string = "foobar"
>>> isinstance(my_string, str)
True

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web