Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #16462
| Date | 2011-11-30 18:12 -0500 |
|---|---|
| From | Terry Reedy <tjreedy@udel.edu> |
| Subject | Re: How convert a list string to a real list |
| References | <CAHbqn4jog2CzT+ahL3XwPZwvAr8eKN3qHsp2yaJk1VYa1157JQ@mail.gmail.com> <jb4jv2$4nt$1@dough.gmane.org> <jb4r6o$ifb$1@dough.gmane.org> <jb69nu$lv6$1@dough.gmane.org> <CACM+9wF0WHUtRMqB5RXMuu82P8QCZgKN74xvk44vGy6DeLJ2+Q@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3182.1322694757.27778.python-list@python.org> (permalink) |
On 11/30/2011 5:48 PM, Hidura wrote:
> Why you don't make this "['1','2','3']".strip("[]").split(',') work for me
Look more carefully. This is not the same as ast.literal_eval().
>>> "['1','2','3']".strip("[]").split(',')
["'1'", "'2'", "'3'"] # list of 3-char strings
>>> ast.literal_eval("['1','2','3']")
['1', '2', '3'] # list of 1-char strings
Even if it were the same, it would be specific to lists of strings and
would not work for anything else.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: How convert a list string to a real list Terry Reedy <tjreedy@udel.edu> - 2011-11-30 18:12 -0500
csiph-web