how to convert a list of strings into a list of variables?

James

Hi might be a simple question. How do i convert this:

mylist = ['table[0].df', 'table[1].df']

to this

mylist = [table[0].df, table[1].df]

Thank you.

Tobias Molenaar

Here is a possible solution using eval. For every item in the list, eval() is used and saved on the same location as the original string.

mylist = ['table[0].df', 'table[1].df']

for i, item in enumerate(mylist):
    mylist[i] = eval(item)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Convert a list of strings to a list of symbols that represent variables

How can I convert a list of strings into sympy variables?

Scala convert list of Strings to multiple variables

How to convert a list of Strings to a LinkedHashMap?

How to convert list of strings into floats?

How to convert a list of strings into a list of objects?

how to convert list of strings to list of guids

Ansible: How to convert list of strings to a list of dictionaries

How to convert a list of strings to list of dictionaries in python?

How to convert nested list of numbers to list of strings?

how to convert list of strings to list of lists

How to convert a nested list of strings to a one list?

How to convert list of strings to list of integers?

How to convert a list of strings into a list of sets?

How to convert a list of numbers to a list of strings?

How to convert list of tuples into list of strings with no commas

Convert a list into a list of strings

How to convert list of list of word strings to strings as sentences?

Converting list of variables to strings

Convert list of strings into list of integers

Convert List of strings to list of structs

convert a list of lists to a list of strings

convert a list of strings list into integers

Convert a list of strings to a list of integers

Convert list of strings to list of expressions?

Take a list and convert it into a list of strings?

Convert a list of integers to list of strings

How to convert a list of ndarray of strings into floats

How to convert list of strings to integer indexes?