8

I have a string: '[1, 2, 3]'
I want to convert it to: [1, 2, 3]

I know there was a single bif that I could use, but I couldn't find it or for the life of me recall what it was.

I know someone out there remembers, any help would be greatly appreciated.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
npengra317
  • 126
  • 2
  • 7

1 Answers1

17

To process a string as if were code:

>>> eval('[1, 2, 3]')
[1, 2, 3]
Tim
  • 41,901
  • 18
  • 127
  • 145
mdurant
  • 27,272
  • 5
  • 45
  • 74