Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
list() object not callable 3.5
-
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!
-
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 namelist
, likelist = [1, 2, 3]
, which hides Python's standardlist
class. To check if that's the issue, typelist
in the console to show the current value of thelist
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 ownlist
variable and makes the built-inlist
visible again. Or simply restart Pythonista. -
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!