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
  • 963,270
  • 265
  • 3,804
  • 3,187
npengra317
  • 123
  • 2
  • 6

1 Answers1

13

To process a string as if were code:

>>> eval('[1, 2, 3]')
[1, 2, 3]
Tim
  • 39,651
  • 17
  • 123
  • 137
mdurant
  • 24,595
  • 5
  • 38
  • 66