Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #25658 > unrolled thread
| Started by | Tim Chase <python.list@tim.thechases.com> |
|---|---|
| First post | 2012-07-19 18:14 -0500 |
| Last post | 2012-07-19 18:14 -0500 |
| 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.
Re: help Tim Chase <python.list@tim.thechases.com> - 2012-07-19 18:14 -0500
| From | Tim Chase <python.list@tim.thechases.com> |
|---|---|
| Date | 2012-07-19 18:14 -0500 |
| Subject | Re: help |
| Message-ID | <mailman.2324.1342739610.4697.python-list@python.org> |
On 07/19/12 17:31, Miriam Gomez Rios wrote:
> Hello, sorry for bothering you, but I have a doubt,
>
> Is there a way to turn this string into a tuplelist??????, I
> need it for gurobi
>
> ('per1','persona1.1','pro1'),('per1','persona1.1','pro2'),('per1','persona1.1','pro3'),...,('per2','persona2.4','pro3'
Assuming a closing paren, you can safely use ast.literal_eval on the
raw string:
import ast
s = "('per1','persona1.1','pro1'),('per1','persona1.1','pro2')"
resulting_tuple_of_tuples = ast.literal_eval(s)
-tkc
Back to top | Article view | comp.lang.python
csiph-web