[Tutor] Turning a string into a tuple?
David L. Lerner
dell2100@prodigy.net
Thu, 27 Sep 2001 01:57:36 -0000
The eval() statement!!!
eval ("['Alda', 11, 9, 6, 'Trey', 10, 12]")
gives me:
['Alda', 11, 9, 6, 'Trey', 10, 12]
I found this five minutes after asking. Thank you for your time.
Is there a searchable index to the python tutor list?
>I need to turn a string:
>"['Alda', 11, 9, 6, 'Trey', 10, 12]"
>into a tuple:
>['Alda', 11, 9, 6, 'Trey', 10, 12]
>This seems like it should be simple, sort of the reverse of string (),
but
>I can't find how to do it. I tried:
>>>> tuple ("['Alda', 11, 9, 6, 'Trey', 10, 12]")
>and I got:
>('[', "'", 'A', 'l', 'd', 'a', "'", ',', ' ', '1', '1', ',', ' ', '9', ',',
>' ', '6', ',', ' ', "'", 'T', 'r', 'e', 'y', "'", ',', ' ', '1', '0', ',',
'
>', '1', '2', ']')
Thank you
David L. Lerner
dell2100@prodigy.net
He's a great artist, but genuine greatness involves great risk. One doesn't
get recognized as great from following a safe path already taken and
approved by others. And risks don't always produce positive results. That's
why they're called risks.
- Scoopy (http://scoopy.net/)