Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: 'builtin_function_or_method' object is not subscriptable

elif( listb[0] == "-test"):     run_all.set("testview")     listb.pop[0] 

ERROR: Exception in Tkinter callback Traceback (most recent call last): File "/tools/python/2.7.2/lib/python2.7/lib-tk/Tkinter.py", line 1410, in call return self.func(*args) File "./edit.py", line 581, in populate listb.pop[0] TypeError: 'builtin_function_or_method' object is not subscriptable

The line # 581 is represented by last pop statement in the code above. run_all is a StringVar.

Why am I getting this error and how can it be solved?

like image 575
Ani Avatar asked Nov 30 '11 07:11

Ani


People also ask

How do you fix an object is not Subscriptable error?

The TypeError: 'int' object is not subscriptable error occurs if we try to index or slice the integer as if it is a subscriptable object like list, dict, or string objects. The issue can be resolved by removing any indexing or slicing to access the values of the integer object.

What is type builtin_function_or_method?

The Python "TypeError: object of type 'builtin_function_or_method' has no len()" occurs when we pass a method or a function without calling it to the len() function. To solve the error, make sure to call the method with parenthesis, e.g. my_method() . Here is an example of how the error occurs. main.py. Copied!

What does type object is not Subscriptable mean in Python?

The “TypeError: 'type' object is not subscriptable” error is raised when you try to access an object using indexing whose data type is “type”. To solve this error, ensure you only try to access iterable objects, like tuples and strings, using indexing. Now you're ready to solve this error like a Python expert!

How do I fix NoneType object is not Subscriptable?

TypeError: 'NoneType' object is not subscriptable Solution The best way to resolve this issue is by not assigning the sort() method to any variable and leaving the numbers. sort() as is.


1 Answers

I think you want

listb.pop()[0] 

The expression listb.pop is a valid python expression which results in a reference to the pop method, but doesn't actually call that method. You need to add the open and close parentheses to call the method.

like image 177
srgerg Avatar answered Sep 18 '22 16:09

srgerg