Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #19669
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'received:verizon.net': 0.07; 'terry': 0.07; 'andres': 0.09; 'list)': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:string': 0.09; 'reedy': 0.16; 'str)': 0.16; 'subject: \n ': 0.16; 'subject:variable': 0.16; 'wrote:': 0.16; '>>>': 0.18; 'jan': 0.19; '(which': 0.19; 'subject:list': 0.21; 'header:In- Reply-To:1': 0.22; '(where': 0.23; 'byte': 0.24; 'pm,': 0.26; 'function': 0.27; "i'm": 0.27; 'lists': 0.28; 'elements': 0.28; 'unicode': 0.28; 'class': 0.29; 'strings.': 0.30; 'subject:?': 0.30; 'list': 0.32; 'header:User-Agent:1': 0.33; 'to:addr:python- list': 0.33; 'hi,': 0.34; 'header:X-Complaints-To:1': 0.34; 'subject:How': 0.35; 'element': 0.36; 'but': 0.37; 'received:org': 0.37; 'subject:can': 0.37; 'should': 0.38; 'subject:: ': 0.39; 'to:addr:python.org': 0.40; 'believe': 0.65; 'receive': 0.68; 'subject:content': 0.84 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Terry Reedy <tjreedy@udel.edu> |
| Subject | Re: How can I verify if the content of a variable is a list or a string? |
| Date | Tue, 31 Jan 2012 19:56:55 -0500 |
| References | <1328057052.56088.YahooMailNeo@web30601.mail.mud.yahoo.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | pool-74-109-121-73.phlapa.fios.verizon.net |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0 |
| In-Reply-To | <1328057052.56088.YahooMailNeo@web30601.mail.mud.yahoo.com> |
| 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.5271.1328057831.27778.python-list@python.org> (permalink) |
| Lines | 20 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1328057831 news.xs4all.nl 6882 [2001:888:2000:d::a6]:40237 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:19669 |
Show key headers only | View raw
On 1/31/2012 7:44 PM, 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. For 3.x, 'list' or 'str' (where 'str' means unicode). For 2.x, I believe 'basestring' includes unicode strings as well as byte strings. >>> isinstance([], list) True >>> isinstance([], str) False -- Terry Jan Reedy
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Re: How can I verify if the content of a variable is a list or a string? Terry Reedy <tjreedy@udel.edu> - 2012-01-31 19:56 -0500
Re: How can I verify if the content of a variable is a list or a string? Rainer Grimm <r.grimm@science-computing.de> - 2012-02-01 23:19 -0800
Re: How can I verify if the content of a variable is a list or a string? Rainer Grimm <r.grimm@science-computing.de> - 2012-02-01 23:19 -0800
Re: How can I verify if the content of a variable is a list or a string? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-02-02 07:31 +0000
csiph-web