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


Groups > comp.lang.python > #52879

Python variable as a string

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <jake.angulo@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'string.': 0.05; 'true,': 0.05; 'subject:Python': 0.06; 'string': 0.09; 'subject:string': 0.09; 'question.': 0.14; "'b'": 0.16; "'c'": 0.16; "['a',": 0.16; 'appreciated!': 0.16; 'evaluating': 0.16; 'subject:variable': 0.16; 'basically': 0.19; 'to:name:python-list@python.org': 0.22; 'evaluation': 0.30; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'maybe': 0.34; 'basic': 0.35; 'received:google.com': 0.35; 'var': 0.36; 'should': 0.36; 'list': 0.37; 'skip:& 10': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'skip:a 30': 0.61; 'name': 0.63; 'refer': 0.63; 'dict()': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=7PsiJSUce3J18Nby7lP/pW1UGxdtb+K6W6PrVJxANxI=; b=Km+oF34oNbyBPmGFBYyVRHSyA9feQ0xF8swMxv2NRxHd/lwDf4TajYcCTBMLo73CjV dvxeqyQvWYbqfLIiWgoFLA/hjr3skg1QnuuoFbc+pXWg5INdG0H9G3LLVavrY8R9gZlW NaKEJiIntsgmSwthrGdjTJkYcXCMU2SgXL8w0fhfRD68OIB+Iy/ATTFjlpfAkT22VhsZ YpZ6qTxAxoTqb6V4jc6ShvW2jLh9U8O1LYdxiCwTUMztZwhPRKn2rXdFvwcSLaV80ml1 5tq2HNmirEZuIa5rFBIrDDfJehgdlBM5uiSakDQYuHOjk8/JnnqeSaZDSXi64wXEYV6a 15AQ==
X-Received by 10.182.128.6 with SMTP id nk6mr19931158obb.11.1377258026440; Fri, 23 Aug 2013 04:40:26 -0700 (PDT)
MIME-Version 1.0
From Jake Angulo <jake.angulo@gmail.com>
Date Fri, 23 Aug 2013 21:40:06 +1000
Subject Python variable as a string
To "python-list@python.org" <python-list@python.org>
Content-Type multipart/alternative; boundary=e89a8ff242a36e1f6e04e49bdf15
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
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.162.1377258034.19984.python-list@python.org> (permalink)
Lines 50
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1377258034 news.xs4all.nl 15959 [2001:888:2000:d::a6]:60118
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:52879

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

Sorry this is a very basic question.

I have a list *var* which after some evaluation I need to refer to *var* as
a string.

Pseudocode:

var = ['a', 'b' , 'c' , 'd']
adict = dict(var='string', anothervar='anotherstring')
anotherdict = dict()
if <condition>:
    anotherdict[akey] = adict['var']


Basically im evaluating the list *var*, and if true, i want to use *var* as
a string so that i can refer to a key-value pair in *adict *(whose key name
is also var for convenience).
*
*
Or maybe i should do things differently?

Any help and code will be appreciated!

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


Thread

Python variable as a string Jake Angulo <jake.angulo@gmail.com> - 2013-08-23 21:40 +1000
  Re: Python variable as a string Neil Cerutti <neilc@norwich.edu> - 2013-08-23 13:23 +0000
    Re: Python variable as a string Jake Angulo <jake.angulo@gmail.com> - 2013-08-24 21:11 +1000
  Re: Python variable as a string Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-08-23 13:40 +0000

csiph-web