Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #52879
| From | Jake Angulo <jake.angulo@gmail.com> |
|---|---|
| Date | 2013-08-23 21:40 +1000 |
| Subject | Python variable as a string |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.162.1377258034.19984.python-list@python.org> (permalink) |
[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 | Next — Next in thread | Find similar | Unroll 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