Forum Archive

list() object not callable 3.5

jeff

Quick question:

The list() function to turn strings/tuples into a list does not seem to work in pythonista with 3.5. I get the error: “‘list’ object is not callable. But run the same script in 2.7 it works. Googling around I didn’t find anything to indicate that list has depreciated.

Here’s an example:
myarray = list('1abcdefg')
print(myarray)

It works in 2.7 but not 3.5. Anyone have an idea on how to convert to a list in pythonista 3.5? Thanks!

dgelessus

The error message means that you are trying to call a list object, and not the list class. This usually happens when you accidentally store a list under the variable name list, like list = [1, 2, 3], which hides Python's standard list class. To check if that's the issue, type list in the console to show the current value of the list variable. By default it will be <class 'list'>, but if you overwrote it, you'll get something like [1, 2, 3].

To fix this, run del list, this removes your own list variable and makes the built-in list visible again. Or simply restart Pythonista.

jeff

I appreciate your answer! Force closing and restarting did the trick. I’ve been downloading tutorial scripts and things from online to help me learn UI module better and I must of have found one that goofed it up. I didn’t realize it would overwrite it from one script to another. Anyway, again, thanks! Cheers!